diff --git a/nwnds_2da/hen_companion.2da b/nwnds_2da/hen_companion.2da index c0bafec60..6cd755626 100644 --- a/nwnds_2da/hen_companion.2da +++ b/nwnds_2da/hen_companion.2da @@ -1,22 +1,22 @@ 2DA V2.0 - NAME BASERESREF STRREF DESCRIPTION -0 Jankx DS_AC_JANKX 16778467 16778468 -1 Wolf NW_AC_WOLF 1578 5929 -2 Bear NW_AC_BEAR 1580 5986 -3 Boar NW_AC_BOAR 1577 5988 -4 Hawk NW_AC_HAWK 5989 5990 -5 Panther NW_AC_PANT 5991 5992 -6 Boneclaw DS_AC_BONECLAW 16778475 16778476 -7 Direwolf NW_AC_DWLF 10526 5994 -8 Direrat X0_AC_DRAT0 3105 9158 -9 Jhakar DS_AC_JHAKAR 16778469 16778470 -10 Cobra NW_AC_COBRA 111372 16789834 -11 Worg NW_AC_WORG 12820 16789835 -12 SandHowler DS_AC_SANDHOWL 16778473 16778474 -13 StinkBeetle NW_AC_STINKB 12409 16789837 -14 Bat NW_AC_BAT 12376 16789838 -15 Carru DS_AC_CARRU 16778477 16778478 -16 Krenshar NW_AC_KRENSHAR 12625 16789840 -17 Z'tal DS_AC_ZTAL 16778471 16778472 -18 CragCat NW_AC_CRAGCAT 57919 16789842 + NAME BASERESREF STRREF DESCRIPTION +0 Jankx DS_AC_JANKX 16778467 16778468 +1 Wolf NW_AC_WOLF 1578 5929 +2 Bear NW_AC_BEAR 1580 5986 +3 Boar NW_AC_BOAR 1577 5988 +4 Hawk NW_AC_HAWK 5989 5990 +5 Panther NW_AC_PANT 5991 5992 +6 Boneclaw DS_AC_BONECLAW 16778475 16778476 +7 Direwolf NW_AC_DWLF 10526 5994 +8 Direrat X0_AC_DRAT0 3105 9158 +9 Jhakar DS_AC_JHAKAR 16778469 16778470 +10 Cobra NW_AC_COBRA 111372 16789834 +11 Worg NW_AC_WORG 12820 16789835 +12 SandHowler DS_AC_SANDHOWL 16778473 16778474 +13 Erdlu DS_AC_ERDLU 16778479 16778480 +14 Bat NW_AC_BAT 12376 16789838 +15 Carru DS_AC_CARRU 16778477 16778478 +16 Krenshar NW_AC_KRENSHAR 12625 16789840 +17 Z'tal DS_AC_ZTAL 16778471 16778472 +18 CragCat NW_AC_CRAGCAT 57919 16789842 diff --git a/nwnds_animalcomp/ds_ac_erdlu01.UTC b/nwnds_animalcomp/ds_ac_erdlu01.UTC new file mode 100644 index 000000000..0c3ea14a1 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu01.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu02.UTC b/nwnds_animalcomp/ds_ac_erdlu02.UTC new file mode 100644 index 000000000..45cb32d42 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu02.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu03.UTC b/nwnds_animalcomp/ds_ac_erdlu03.UTC new file mode 100644 index 000000000..d84cad9e4 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu03.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu04.UTC b/nwnds_animalcomp/ds_ac_erdlu04.UTC new file mode 100644 index 000000000..1bc707419 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu04.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu05.UTC b/nwnds_animalcomp/ds_ac_erdlu05.UTC new file mode 100644 index 000000000..9ce4d3162 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu05.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu06.UTC b/nwnds_animalcomp/ds_ac_erdlu06.UTC new file mode 100644 index 000000000..bb66528ba Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu06.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu07.UTC b/nwnds_animalcomp/ds_ac_erdlu07.UTC new file mode 100644 index 000000000..7d2f4dcb2 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu07.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu08.UTC b/nwnds_animalcomp/ds_ac_erdlu08.UTC new file mode 100644 index 000000000..26eb1d718 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu08.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu09.UTC b/nwnds_animalcomp/ds_ac_erdlu09.UTC new file mode 100644 index 000000000..d72544026 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu09.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu10.UTC b/nwnds_animalcomp/ds_ac_erdlu10.UTC new file mode 100644 index 000000000..80d781918 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu10.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu11.UTC b/nwnds_animalcomp/ds_ac_erdlu11.UTC new file mode 100644 index 000000000..a4fc6ed6b Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu11.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu12.UTC b/nwnds_animalcomp/ds_ac_erdlu12.UTC new file mode 100644 index 000000000..f41be08ae Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu12.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu13.UTC b/nwnds_animalcomp/ds_ac_erdlu13.UTC new file mode 100644 index 000000000..69f07985a Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu13.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu14.UTC b/nwnds_animalcomp/ds_ac_erdlu14.UTC new file mode 100644 index 000000000..16713364b Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu14.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu15.UTC b/nwnds_animalcomp/ds_ac_erdlu15.UTC new file mode 100644 index 000000000..e1069f5c0 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu15.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu16.UTC b/nwnds_animalcomp/ds_ac_erdlu16.UTC new file mode 100644 index 000000000..ffd98e1ae Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu16.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu17.UTC b/nwnds_animalcomp/ds_ac_erdlu17.UTC new file mode 100644 index 000000000..ce0ee444d Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu17.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu18.UTC b/nwnds_animalcomp/ds_ac_erdlu18.UTC new file mode 100644 index 000000000..203e544a0 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu18.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu19.UTC b/nwnds_animalcomp/ds_ac_erdlu19.UTC new file mode 100644 index 000000000..64ee0cc14 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu19.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu20.UTC b/nwnds_animalcomp/ds_ac_erdlu20.UTC new file mode 100644 index 000000000..52fcd51e8 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu20.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu21.UTC b/nwnds_animalcomp/ds_ac_erdlu21.UTC new file mode 100644 index 000000000..5989ca50c Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu21.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu22.UTC b/nwnds_animalcomp/ds_ac_erdlu22.UTC new file mode 100644 index 000000000..2ff27469f Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu22.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu23.UTC b/nwnds_animalcomp/ds_ac_erdlu23.UTC new file mode 100644 index 000000000..8091d8230 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu23.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu24.UTC b/nwnds_animalcomp/ds_ac_erdlu24.UTC new file mode 100644 index 000000000..42aa8eb56 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu24.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu25.UTC b/nwnds_animalcomp/ds_ac_erdlu25.UTC new file mode 100644 index 000000000..ca49344dd Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu25.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu26.UTC b/nwnds_animalcomp/ds_ac_erdlu26.UTC new file mode 100644 index 000000000..d8f36f122 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu26.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu27.UTC b/nwnds_animalcomp/ds_ac_erdlu27.UTC new file mode 100644 index 000000000..5d72421c9 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu27.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu28.UTC b/nwnds_animalcomp/ds_ac_erdlu28.UTC new file mode 100644 index 000000000..9eac53e6c Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu28.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu29.UTC b/nwnds_animalcomp/ds_ac_erdlu29.UTC new file mode 100644 index 000000000..d600f4678 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu29.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu30.UTC b/nwnds_animalcomp/ds_ac_erdlu30.UTC new file mode 100644 index 000000000..d3743b24d Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu30.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu31.UTC b/nwnds_animalcomp/ds_ac_erdlu31.UTC new file mode 100644 index 000000000..57cc4541d Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu31.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu32.UTC b/nwnds_animalcomp/ds_ac_erdlu32.UTC new file mode 100644 index 000000000..d34f0ea09 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu32.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu33.UTC b/nwnds_animalcomp/ds_ac_erdlu33.UTC new file mode 100644 index 000000000..02ccff74d Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu33.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu34.UTC b/nwnds_animalcomp/ds_ac_erdlu34.UTC new file mode 100644 index 000000000..e7b6657fa Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu34.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu35.UTC b/nwnds_animalcomp/ds_ac_erdlu35.UTC new file mode 100644 index 000000000..7d588406b Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu35.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu36.UTC b/nwnds_animalcomp/ds_ac_erdlu36.UTC new file mode 100644 index 000000000..c096a367b Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu36.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu37.UTC b/nwnds_animalcomp/ds_ac_erdlu37.UTC new file mode 100644 index 000000000..81958f337 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu37.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu38.UTC b/nwnds_animalcomp/ds_ac_erdlu38.UTC new file mode 100644 index 000000000..5c6ce9635 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu38.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu39.UTC b/nwnds_animalcomp/ds_ac_erdlu39.UTC new file mode 100644 index 000000000..2949a1d02 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu39.UTC differ diff --git a/nwnds_animalcomp/ds_ac_erdlu40.UTC b/nwnds_animalcomp/ds_ac_erdlu40.UTC new file mode 100644 index 000000000..66c6a9471 Binary files /dev/null and b/nwnds_animalcomp/ds_ac_erdlu40.UTC differ diff --git a/nwnds_compiled_mod/nwn_dark_sun.7z b/nwnds_compiled_mod/nwn_dark_sun.7z index d02ac2ea1..93e086573 100644 Binary files a/nwnds_compiled_mod/nwn_dark_sun.7z and b/nwnds_compiled_mod/nwn_dark_sun.7z differ diff --git a/nwnds_module/creaturepalcus.itp b/nwnds_module/creaturepalcus.itp index 4c71937d8..fdc0ffd7b 100644 Binary files a/nwnds_module/creaturepalcus.itp and b/nwnds_module/creaturepalcus.itp differ diff --git a/nwnds_module/dante_letodel_at.nss b/nwnds_module/dante_letodel_at.nss index bd1a313e6..3000d4ddb 100644 --- a/nwnds_module/dante_letodel_at.nss +++ b/nwnds_module/dante_letodel_at.nss @@ -1,11 +1,10 @@ // This is the script dante_letodel_at -//#include "delchar_include" -//#include "aps_include" -//#include "sha_subr_consts" +#include "delchar_include" +#include "aps_include" //void DeletePCSubRace(string sPlayer,string sCharName); -/*void main() +void main() { object oPlayer = GetPCSpeaker(); string sName = GetName(oPlayer); @@ -22,11 +21,10 @@ SendMessageToAllDMs("PC Player Name: "+sPlayer+" just tried to delete a character without a name."); WriteTimestampedLogEntry("PC Player Name: "+sPlayer+" just tried to delete a character without a name."); } -}*/ +} - -/* void DeletePCSubRace(string sPlayer,string sCharName) +/*void DeletePCSubRace(string sPlayer,string sCharName) { sPlayer = SQLEncodeSpecialChars(sPlayer); @@ -70,13 +68,10 @@ } return; - } */ + } /* // player not found in db.. may need manual delete SendMessageToAllDMs("Error Deleting PC from Subrace DB: Player/PC not found: " + sPlayer + "/" + sCharName + "May need manual delete "); return;*/ //} - - - diff --git a/nwnds_module/delchar_include.ncs b/nwnds_module/delchar_include.ncs new file mode 100644 index 000000000..ecb1c72d2 Binary files /dev/null and b/nwnds_module/delchar_include.ncs differ diff --git a/nwnds_module/delchar_include.nss b/nwnds_module/delchar_include.nss index 68f8452be..aa739890a 100644 --- a/nwnds_module/delchar_include.nss +++ b/nwnds_module/delchar_include.nss @@ -18,8 +18,10 @@ /* Implementation */ /************************************/ -/*void deletechar(string sPlayerName, string sCharName) +//void main (){} + +void deletechar(string sPlayerName, string sCharName) { object oModule = GetModule(); SetLocalString(oModule, "NWNX!DELETECHAR!DELETE", sPlayerName + "?" + sCharName); -} */ \ No newline at end of file +} diff --git a/nwnds_module/dm_shadowroom.are b/nwnds_module/dm_shadowroom.are index acbcefe8c..844168cca 100644 Binary files a/nwnds_module/dm_shadowroom.are and b/nwnds_module/dm_shadowroom.are differ diff --git a/nwnds_module/ds_ac_erdlu01.UTC b/nwnds_module/ds_ac_erdlu01.UTC new file mode 100644 index 000000000..0c3ea14a1 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu01.UTC differ diff --git a/nwnds_module/ds_ac_erdlu02.UTC b/nwnds_module/ds_ac_erdlu02.UTC new file mode 100644 index 000000000..45cb32d42 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu02.UTC differ diff --git a/nwnds_module/ds_ac_erdlu03.UTC b/nwnds_module/ds_ac_erdlu03.UTC new file mode 100644 index 000000000..d84cad9e4 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu03.UTC differ diff --git a/nwnds_module/ds_ac_erdlu04.UTC b/nwnds_module/ds_ac_erdlu04.UTC new file mode 100644 index 000000000..1bc707419 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu04.UTC differ diff --git a/nwnds_module/ds_ac_erdlu05.UTC b/nwnds_module/ds_ac_erdlu05.UTC new file mode 100644 index 000000000..9ce4d3162 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu05.UTC differ diff --git a/nwnds_module/ds_ac_erdlu06.UTC b/nwnds_module/ds_ac_erdlu06.UTC new file mode 100644 index 000000000..bb66528ba Binary files /dev/null and b/nwnds_module/ds_ac_erdlu06.UTC differ diff --git a/nwnds_module/ds_ac_erdlu07.UTC b/nwnds_module/ds_ac_erdlu07.UTC new file mode 100644 index 000000000..7d2f4dcb2 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu07.UTC differ diff --git a/nwnds_module/ds_ac_erdlu08.UTC b/nwnds_module/ds_ac_erdlu08.UTC new file mode 100644 index 000000000..26eb1d718 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu08.UTC differ diff --git a/nwnds_module/ds_ac_erdlu09.UTC b/nwnds_module/ds_ac_erdlu09.UTC new file mode 100644 index 000000000..d72544026 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu09.UTC differ diff --git a/nwnds_module/ds_ac_erdlu10.UTC b/nwnds_module/ds_ac_erdlu10.UTC new file mode 100644 index 000000000..80d781918 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu10.UTC differ diff --git a/nwnds_module/ds_ac_erdlu11.UTC b/nwnds_module/ds_ac_erdlu11.UTC new file mode 100644 index 000000000..a4fc6ed6b Binary files /dev/null and b/nwnds_module/ds_ac_erdlu11.UTC differ diff --git a/nwnds_module/ds_ac_erdlu12.UTC b/nwnds_module/ds_ac_erdlu12.UTC new file mode 100644 index 000000000..f41be08ae Binary files /dev/null and b/nwnds_module/ds_ac_erdlu12.UTC differ diff --git a/nwnds_module/ds_ac_erdlu13.UTC b/nwnds_module/ds_ac_erdlu13.UTC new file mode 100644 index 000000000..69f07985a Binary files /dev/null and b/nwnds_module/ds_ac_erdlu13.UTC differ diff --git a/nwnds_module/ds_ac_erdlu14.UTC b/nwnds_module/ds_ac_erdlu14.UTC new file mode 100644 index 000000000..16713364b Binary files /dev/null and b/nwnds_module/ds_ac_erdlu14.UTC differ diff --git a/nwnds_module/ds_ac_erdlu15.UTC b/nwnds_module/ds_ac_erdlu15.UTC new file mode 100644 index 000000000..e1069f5c0 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu15.UTC differ diff --git a/nwnds_module/ds_ac_erdlu16.UTC b/nwnds_module/ds_ac_erdlu16.UTC new file mode 100644 index 000000000..ffd98e1ae Binary files /dev/null and b/nwnds_module/ds_ac_erdlu16.UTC differ diff --git a/nwnds_module/ds_ac_erdlu17.UTC b/nwnds_module/ds_ac_erdlu17.UTC new file mode 100644 index 000000000..ce0ee444d Binary files /dev/null and b/nwnds_module/ds_ac_erdlu17.UTC differ diff --git a/nwnds_module/ds_ac_erdlu18.UTC b/nwnds_module/ds_ac_erdlu18.UTC new file mode 100644 index 000000000..203e544a0 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu18.UTC differ diff --git a/nwnds_module/ds_ac_erdlu19.UTC b/nwnds_module/ds_ac_erdlu19.UTC new file mode 100644 index 000000000..64ee0cc14 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu19.UTC differ diff --git a/nwnds_module/ds_ac_erdlu20.UTC b/nwnds_module/ds_ac_erdlu20.UTC new file mode 100644 index 000000000..52fcd51e8 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu20.UTC differ diff --git a/nwnds_module/ds_ac_erdlu21.UTC b/nwnds_module/ds_ac_erdlu21.UTC new file mode 100644 index 000000000..5989ca50c Binary files /dev/null and b/nwnds_module/ds_ac_erdlu21.UTC differ diff --git a/nwnds_module/ds_ac_erdlu22.UTC b/nwnds_module/ds_ac_erdlu22.UTC new file mode 100644 index 000000000..2ff27469f Binary files /dev/null and b/nwnds_module/ds_ac_erdlu22.UTC differ diff --git a/nwnds_module/ds_ac_erdlu23.UTC b/nwnds_module/ds_ac_erdlu23.UTC new file mode 100644 index 000000000..8091d8230 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu23.UTC differ diff --git a/nwnds_module/ds_ac_erdlu24.UTC b/nwnds_module/ds_ac_erdlu24.UTC new file mode 100644 index 000000000..42aa8eb56 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu24.UTC differ diff --git a/nwnds_module/ds_ac_erdlu25.UTC b/nwnds_module/ds_ac_erdlu25.UTC new file mode 100644 index 000000000..ca49344dd Binary files /dev/null and b/nwnds_module/ds_ac_erdlu25.UTC differ diff --git a/nwnds_module/ds_ac_erdlu26.UTC b/nwnds_module/ds_ac_erdlu26.UTC new file mode 100644 index 000000000..d8f36f122 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu26.UTC differ diff --git a/nwnds_module/ds_ac_erdlu27.UTC b/nwnds_module/ds_ac_erdlu27.UTC new file mode 100644 index 000000000..5d72421c9 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu27.UTC differ diff --git a/nwnds_module/ds_ac_erdlu28.UTC b/nwnds_module/ds_ac_erdlu28.UTC new file mode 100644 index 000000000..9eac53e6c Binary files /dev/null and b/nwnds_module/ds_ac_erdlu28.UTC differ diff --git a/nwnds_module/ds_ac_erdlu29.UTC b/nwnds_module/ds_ac_erdlu29.UTC new file mode 100644 index 000000000..d600f4678 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu29.UTC differ diff --git a/nwnds_module/ds_ac_erdlu30.UTC b/nwnds_module/ds_ac_erdlu30.UTC new file mode 100644 index 000000000..d3743b24d Binary files /dev/null and b/nwnds_module/ds_ac_erdlu30.UTC differ diff --git a/nwnds_module/ds_ac_erdlu31.UTC b/nwnds_module/ds_ac_erdlu31.UTC new file mode 100644 index 000000000..57cc4541d Binary files /dev/null and b/nwnds_module/ds_ac_erdlu31.UTC differ diff --git a/nwnds_module/ds_ac_erdlu32.UTC b/nwnds_module/ds_ac_erdlu32.UTC new file mode 100644 index 000000000..d34f0ea09 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu32.UTC differ diff --git a/nwnds_module/ds_ac_erdlu33.UTC b/nwnds_module/ds_ac_erdlu33.UTC new file mode 100644 index 000000000..02ccff74d Binary files /dev/null and b/nwnds_module/ds_ac_erdlu33.UTC differ diff --git a/nwnds_module/ds_ac_erdlu34.UTC b/nwnds_module/ds_ac_erdlu34.UTC new file mode 100644 index 000000000..e7b6657fa Binary files /dev/null and b/nwnds_module/ds_ac_erdlu34.UTC differ diff --git a/nwnds_module/ds_ac_erdlu35.UTC b/nwnds_module/ds_ac_erdlu35.UTC new file mode 100644 index 000000000..7d588406b Binary files /dev/null and b/nwnds_module/ds_ac_erdlu35.UTC differ diff --git a/nwnds_module/ds_ac_erdlu36.UTC b/nwnds_module/ds_ac_erdlu36.UTC new file mode 100644 index 000000000..c096a367b Binary files /dev/null and b/nwnds_module/ds_ac_erdlu36.UTC differ diff --git a/nwnds_module/ds_ac_erdlu37.UTC b/nwnds_module/ds_ac_erdlu37.UTC new file mode 100644 index 000000000..81958f337 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu37.UTC differ diff --git a/nwnds_module/ds_ac_erdlu38.UTC b/nwnds_module/ds_ac_erdlu38.UTC new file mode 100644 index 000000000..5c6ce9635 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu38.UTC differ diff --git a/nwnds_module/ds_ac_erdlu39.UTC b/nwnds_module/ds_ac_erdlu39.UTC new file mode 100644 index 000000000..2949a1d02 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu39.UTC differ diff --git a/nwnds_module/ds_ac_erdlu40.UTC b/nwnds_module/ds_ac_erdlu40.UTC new file mode 100644 index 000000000..66c6a9471 Binary files /dev/null and b/nwnds_module/ds_ac_erdlu40.UTC differ diff --git a/nwnds_module/nwnx.nss b/nwnds_module/nwnx.nss new file mode 100644 index 000000000..fe8942cf2 --- /dev/null +++ b/nwnds_module/nwnx.nss @@ -0,0 +1,113 @@ +/// @addtogroup nwnx NWNX +/// @brief Functions for plugin developers. +/// @{ +/// @file nwnx.nss + +/// @brief Scripting interface to NWNX. +/// @param pluginName The plugin name. +/// @param functionName The function name (do not include NWNX_Plugin_). +void NWNX_CallFunction(string pluginName, string functionName); +/// @brief Pushes the specified type to the c++ side +/// @param pluginName The plugin name. +/// @param functionName The function name (do not include NWNX_Plugin_). +/// @param value The value of specified type to push. +void NWNX_PushArgumentInt(string pluginName, string functionName, int value); +/// @copydoc NWNX_PushArgumentInt() +void NWNX_PushArgumentFloat(string pluginName, string functionName, float value); +/// @copydoc NWNX_PushArgumentInt() +void NWNX_PushArgumentObject(string pluginName, string functionName, object value); +/// @copydoc NWNX_PushArgumentInt() +void NWNX_PushArgumentString(string pluginName, string functionName, string value); +/// @copydoc NWNX_PushArgumentInt() +void NWNX_PushArgumentEffect(string pluginName, string functionName, effect value); +/// @copydoc NWNX_PushArgumentInt() +void NWNX_PushArgumentItemProperty(string pluginName, string functionName, itemproperty value); +/// @brief Returns the specified type from the c++ side +/// @param pluginName The plugin name. +/// @param functionName The function name (do not include NWNX_Plugin_). +/// @return The value of specified type. +int NWNX_GetReturnValueInt(string pluginName, string functionName); +/// @copydoc NWNX_GetReturnValueInt() +float NWNX_GetReturnValueFloat(string pluginName, string functionName); +/// @copydoc NWNX_GetReturnValueInt() +object NWNX_GetReturnValueObject(string pluginName, string functionName); +/// @copydoc NWNX_GetReturnValueInt() +string NWNX_GetReturnValueString(string pluginName, string functionName); +/// @copydoc NWNX_GetReturnValueInt() +effect NWNX_GetReturnValueEffect(string pluginName, string functionName); +/// @copydoc NWNX_GetReturnValueInt() +itemproperty NWNX_GetReturnValueItemProperty(string pluginName, string functionName); + +/// @private +string NWNX_INTERNAL_BuildString(string pluginName, string functionName, string operation) +{ + return "NWNXEE!ABIv2!" + pluginName + "!" + functionName + "!" + operation; +} +/// @} + +void NWNX_CallFunction(string pluginName, string functionName) +{ + PlaySound(NWNX_INTERNAL_BuildString(pluginName, functionName, "CALL")); +} + +void NWNX_PushArgumentInt(string pluginName, string functionName, int value) +{ + SetLocalInt(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH"), value); +} + +void NWNX_PushArgumentFloat(string pluginName, string functionName, float value) +{ + SetLocalFloat(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH"), value); +} + +void NWNX_PushArgumentObject(string pluginName, string functionName, object value) +{ + SetLocalObject(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH"), value); +} + +void NWNX_PushArgumentString(string pluginName, string functionName, string value) +{ + SetLocalString(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH"), value); +} + +void NWNX_PushArgumentEffect(string pluginName, string functionName, effect value) +{ + TagEffect(value, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH")); +} + +void NWNX_PushArgumentItemProperty(string pluginName, string functionName, itemproperty value) +{ + TagItemProperty(value, NWNX_INTERNAL_BuildString(pluginName, functionName, "PUSH")); +} + +int NWNX_GetReturnValueInt(string pluginName, string functionName) +{ + return GetLocalInt(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} + +float NWNX_GetReturnValueFloat(string pluginName, string functionName) +{ + return GetLocalFloat(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} + +object NWNX_GetReturnValueObject(string pluginName, string functionName) +{ + return GetLocalObject(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} + +string NWNX_GetReturnValueString(string pluginName, string functionName) +{ + return GetLocalString(OBJECT_INVALID, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} + +effect NWNX_GetReturnValueEffect(string pluginName, string functionName) +{ + effect e; + return TagEffect(e, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} + +itemproperty NWNX_GetReturnValueItemProperty(string pluginName, string functionName) +{ + itemproperty ip; + return TagItemProperty(ip, NWNX_INTERNAL_BuildString(pluginName, functionName, "POP")); +} diff --git a/nwnds_module/nwnx_admin.nss b/nwnds_module/nwnx_admin.nss new file mode 100644 index 000000000..bbb43df96 --- /dev/null +++ b/nwnds_module/nwnx_admin.nss @@ -0,0 +1,344 @@ +/// @addtogroup admin Administration +/// @brief Various admin related functions +/// @{ +/// @file nwnx_admin.nss +#include "nwnx" + +const string NWNX_Administration = "NWNX_Administration"; ///< @private + +/// @name Administration Options +/// @anchor admin_opts +/// +/// @{ +const int NWNX_ADMINISTRATION_OPTION_ALL_KILLABLE = 0; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_NON_PARTY_KILLABLE = 1; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_REQUIRE_RESURRECTION = 2; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_LOSE_STOLEN_ITEMS = 3; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_LOSE_ITEMS = 4; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_LOSE_EXP = 5; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_LOSE_GOLD = 6; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_LOSE_GOLD_NUM = 7; +const int NWNX_ADMINISTRATION_OPTION_LOSE_EXP_NUM = 8; +const int NWNX_ADMINISTRATION_OPTION_LOSE_ITEMS_NUM = 9; +const int NWNX_ADMINISTRATION_OPTION_PVP_SETTING = 10; // 0 = No PVP, 1 = Party PVP, 2 = Full PVP +const int NWNX_ADMINISTRATION_OPTION_PAUSE_AND_PLAY = 11; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_ONE_PARTY_ONLY = 12; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_ENFORCE_LEGAL_CHARACTERS = 13; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_ITEM_LEVEL_RESTRICTIONS = 14; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_CDKEY_BANLIST_ALLOWLIST = 15; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_DISALLOW_SHOUTING = 16; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_SHOW_DM_JOIN_MESSAGE = 17; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_BACKUP_SAVED_CHARACTERS = 18; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_AUTO_FAIL_SAVE_ON_1 = 19; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_VALIDATE_SPELLS = 20; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_EXAMINE_EFFECTS = 21; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_EXAMINE_CHALLENGE_RATING = 22; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_USE_MAX_HITPOINTS = 23; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_RESTORE_SPELLS_USES = 24; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_RESET_ENCOUNTER_SPAWN_POOL = 25; // TRUE/FALSE +const int NWNX_ADMINISTRATION_OPTION_HIDE_HITPOINTS_GAINED = 26; // TRUE/FALSE +/// @} + +/// @name Administration Debug Types +/// @anchor admin_debug +/// +/// @{ +const int NWNX_ADMINISTRATION_DEBUG_COMBAT = 0; // TRUE/FALSE +const int NWNX_ADMINISTRATION_DEBUG_SAVING_THROW = 1; // TRUE/FALSE +const int NWNX_ADMINISTRATION_DEBUG_MOVEMENT_SPEED = 2; // TRUE/FALSE +const int NWNX_ADMINISTRATION_DEBUG_HIT_DIE = 3; // TRUE/FALSE +/// @} + +/// @brief Gets the current player password. +/// @return The current player password. +string NWNX_Administration_GetPlayerPassword(); + +/// @brief Sets the password for players to login. +/// @param password The password to use. +void NWNX_Administration_SetPlayerPassword(string password); + +/// @brief Clears the player password required to login. +void NWNX_Administration_ClearPlayerPassword(); + +/// @brief Gets the current DM password. +/// @return The current DM password. +string NWNX_Administration_GetDMPassword(); + +/// @brief Sets the password for DMs to login. +/// @param password The password to use. +void NWNX_Administration_SetDMPassword(string password); + +/// @brief Signals the server to immediately shut down. +void NWNX_Administration_ShutdownServer(); + +/// @brief Deletes the player character from the servervault +/// +/// The PC will be immediately booted from the game with a "Delete Character" message +/// +/// @param oPC The player to delete. +/// @param bPreserveBackup If true, it will leave the file on server, only appending ".deleted0" to the bic filename. +/// @param sKickMessage An optional kick message, if left blank it will default to "Delete Character" as reason. +void NWNX_Administration_DeletePlayerCharacter(object oPC, int bPreserveBackup = TRUE, string sKickMessage = ""); + +/// @brief Bans the provided IP. +/// @param ip The IP Address to ban. +void NWNX_Administration_AddBannedIP(string ip); + +/// @brief Removes the ban on the provided IP. +/// @param ip The IP Address to unban. +void NWNX_Administration_RemoveBannedIP(string ip); + +/// @brief Bans the provided Public CD Key. +/// @param key The Public CD Key to ban. +void NWNX_Administration_AddBannedCDKey(string key); + +/// @brief Removes the ban on the provided Public CD Key. +/// @param key The Public CD Key to unban. +void NWNX_Administration_RemoveBannedCDKey(string key); + +/// @brief Bans the provided playername. +/// @param playerName The player name (community name) to ban. +/// @warning A user can change their playername at will. +void NWNX_Administration_AddBannedPlayerName(string playerName); + +/// @brief Removes the ban on the provided playername. +/// @param playerName The player name (community name) to unban. +void NWNX_Administration_RemoveBannedPlayerName(string playerName); + +/// @brief Get a list of all banned IPs/Keys/names as a string. +/// @return A string with a listing of the banned IPs/Keys/names. +string NWNX_Administration_GetBannedList(); + +/// @brief Set the module's name as shown to the serverlist. +/// @param name The name to give the module. +void NWNX_Administration_SetModuleName(string name); + +/// @brief Set the server's name as shown to the serverlist. +/// @param name The name to give the server. +void NWNX_Administration_SetServerName(string name); + +/// @brief Returns the server's name as shown to the serverlist. +string NWNX_Administration_GetServerName(); + +/// @brief Get an @ref admin_opts "Administration Option" value. +/// @param option An @ref admin_opts "Administration Option". +/// @return The current setting for the supplied option from @ref admin_opts "Administration Options". +int NWNX_Administration_GetPlayOption(int option); + +/// @brief Set an @ref admin_opts "Administration Options" to a value. +/// @param option The option to adjust from @ref admin_opts "Administration Options". +/// @param value The new value for the option. +void NWNX_Administration_SetPlayOption(int option, int value); + +/// @brief Delete the TURD of playerName + characterName. +/// +/// At times a PC may get stuck in a permanent crash loop when attempting to log +/// in. This function allows administrators to delete their Temporary User +/// Resource Data where the PC's current location is stored allowing them to log +/// into the starting area. +/// +/// @param playerName The community (login name). +/// @param characterName The character name. +/// @return Returns TRUE if successful +int NWNX_Administration_DeleteTURD(string playerName, string characterName); + +/// @brief Get an @ref admin_debug "Administration Debug Type" value. +/// @param type An @ref admin_debug "Administration Debug Type". +/// @return The current value for the supplied debug type from @ref admin_debug "Administration Debug Types". +int NWNX_Administration_GetDebugValue(int type); + +/// @brief Set an @ref admin_debug "Administration Debug Type" to a value. +/// @param type The debug type to adjust from @ref admin_debug "Administration Debug Types". +/// @param state The new state for the debug type, TRUE or FALSE +void NWNX_Administration_SetDebugValue(int type, int state); + +/// @brief Reload all rules (2da stuff etc). +/// @warning DANGER, DRAGONS. Bad things may or may not happen. +void NWNX_Administration_ReloadRules(); + +/// @} + +string NWNX_Administration_GetPlayerPassword() +{ + string sFunc = "GetPlayerPassword"; + + NWNX_CallFunction(NWNX_Administration, sFunc); + return NWNX_GetReturnValueString(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetPlayerPassword(string password) +{ + string sFunc = "SetPlayerPassword"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, password); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_ClearPlayerPassword() +{ + string sFunc = "ClearPlayerPassword"; + + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +string NWNX_Administration_GetDMPassword() +{ + string sFunc = "GetDMPassword"; + + NWNX_CallFunction(NWNX_Administration, sFunc); + return NWNX_GetReturnValueString(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetDMPassword(string password) +{ + string sFunc = "SetDMPassword"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, password); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_ShutdownServer() +{ + string sFunc = "ShutdownServer"; + + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_DeletePlayerCharacter(object oPC, int bPreserveBackup = TRUE, string sKickMessage = "") +{ + string sFunc = "DeletePlayerCharacter"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, sKickMessage); + NWNX_PushArgumentInt(NWNX_Administration, sFunc, bPreserveBackup); + NWNX_PushArgumentObject(NWNX_Administration, sFunc, oPC); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_AddBannedIP(string ip) +{ + string sFunc = "AddBannedIP"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, ip); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +void NWNX_Administration_RemoveBannedIP(string ip) +{ + string sFunc = "RemoveBannedIP"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, ip); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +void NWNX_Administration_AddBannedCDKey(string key) +{ + string sFunc = "AddBannedCDKey"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, key); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +void NWNX_Administration_RemoveBannedCDKey(string key) +{ + string sFunc = "RemoveBannedCDKey"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, key); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +void NWNX_Administration_AddBannedPlayerName(string playerName) +{ + string sFunc = "AddBannedPlayerName"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, playerName); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +void NWNX_Administration_RemoveBannedPlayerName(string playerName) +{ + string sFunc = "RemoveBannedPlayerName"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, playerName); + NWNX_CallFunction(NWNX_Administration, sFunc); +} +string NWNX_Administration_GetBannedList() +{ + string sFunc = "GetBannedList"; + + NWNX_CallFunction(NWNX_Administration, sFunc); + return NWNX_GetReturnValueString(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetModuleName(string name) +{ + string sFunc = "SetModuleName"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, name); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetServerName(string name) +{ + string sFunc = "SetServerName"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, name); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +string NWNX_Administration_GetServerName() +{ + string sFunc = "GetServerName"; + NWNX_CallFunction(NWNX_Administration, sFunc); + return NWNX_GetReturnValueString(NWNX_Administration, sFunc); +} + +int NWNX_Administration_GetPlayOption(int option) +{ + string sFunc = "GetPlayOption"; + + NWNX_PushArgumentInt(NWNX_Administration, sFunc, option); + NWNX_CallFunction(NWNX_Administration, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetPlayOption(int option, int value) +{ + string sFunc = "SetPlayOption"; + + NWNX_PushArgumentInt(NWNX_Administration, sFunc, value); + NWNX_PushArgumentInt(NWNX_Administration, sFunc, option); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +int NWNX_Administration_DeleteTURD(string playerName, string characterName) +{ + string sFunc = "DeleteTURD"; + + NWNX_PushArgumentString(NWNX_Administration, sFunc, characterName); + NWNX_PushArgumentString(NWNX_Administration, sFunc, playerName); + NWNX_CallFunction(NWNX_Administration, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Administration, sFunc); +} + +int NWNX_Administration_GetDebugValue(int type) +{ + string sFunc = "GetDebugValue"; + + NWNX_PushArgumentInt(NWNX_Administration, sFunc, type); + NWNX_CallFunction(NWNX_Administration, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Administration, sFunc); +} + +void NWNX_Administration_SetDebugValue(int type, int state) +{ + string sFunc = "SetDebugValue"; + + NWNX_PushArgumentInt(NWNX_Administration, sFunc, state); + NWNX_PushArgumentInt(NWNX_Administration, sFunc, type); + NWNX_CallFunction(NWNX_Administration, sFunc); +} + +void NWNX_Administration_ReloadRules() +{ + string sFunc = "ReloadRules"; + + NWNX_CallFunction(NWNX_Administration, sFunc); +} diff --git a/nwnds_module/nwnx_appearance.nss b/nwnds_module/nwnx_appearance.nss new file mode 100644 index 000000000..6f31140ac --- /dev/null +++ b/nwnds_module/nwnx_appearance.nss @@ -0,0 +1,73 @@ +/// @addtogroup appearance Appearance +/// @brief Allows the appearance and some other things of creatures to be overridden per player. +/// @{ +/// @file nwnx_appearance.nss +#include "nwnx" + +const string NWNX_Appearance = "NWNX_Appearance"; ///< @private + +/// @name Appearance Types +/// @anchor appearance_types +/// +/// The various types of changes that can be made to how a PC is perceived. +/// @{ +const int NWNX_APPEARANCE_TYPE_APPEARANCE = 0; ///< APPEARANCE_TYPE_* or -1 to remove +const int NWNX_APPEARANCE_TYPE_GENDER = 1; ///< GENDER_* or -1 to remove + +/// @brief 0-GetMaxHitPoints(oCreature) or -1 to remove +/// @note This is visual only. Does not change the Examine Window health status. +const int NWNX_APPEARANCE_TYPE_HITPOINTS = 2; +const int NWNX_APPEARANCE_TYPE_HAIR_COLOR = 3; ///< 0-175 or -1 to remove +const int NWNX_APPEARANCE_TYPE_SKIN_COLOR = 4; ///< 0-175 or -1 to remove +const int NWNX_APPEARANCE_TYPE_PHENOTYPE = 5; ///< PHENOTYPE_* or -1 to remove +const int NWNX_APPEARANCE_TYPE_HEAD_TYPE = 6; ///< 0-? or -1 to remove +const int NWNX_APPEARANCE_TYPE_SOUNDSET = 7; ///< See soundset.2da or -1 to remove +const int NWNX_APPEARANCE_TYPE_TAIL_TYPE = 8; ///< CREATURE_TAIL_TYPE_* or see tailmodel.2da, -1 to remove +const int NWNX_APPEARANCE_TYPE_WING_TYPE = 9; ///< CREATURE_WING_TYPE_* or see wingmodel.2da, -1 to remove +const int NWNX_APPEARANCE_TYPE_FOOTSTEP_SOUND = 10; ///< 0-17 or see footstepsounds.2da, -1 to remove + +/// @brief See portraits.2da, -1 to remove +/// @note Does not change the Examine Window portrait. +const int NWNX_APPEARANCE_TYPE_PORTRAIT = 11; +///@} + +/// @brief Override a creature's appearance type for a player. +/// @param oPlayer The player who will see/hear things differently. +/// @param oCreature The target creature whose appearance type to alter for oPlayer. Can be a PC. +/// @param nType The @ref appearance_types "Appearance Type" to set or -1 to fully remove override. +/// @param nValue The new value for the appearance type. +void NWNX_Appearance_SetOverride(object oPlayer, object oCreature, int nType, int nValue); + +/// @brief Get a creature's appearance type for a player. +/// @param oPlayer The player who see/hear things differently. +/// @param oCreature The target creature whose appearance type is altered for oPlayer. Can be a PC. +/// @param nType The @ref appearance_types "Appearance Type" to get. +/// @return The value for the appearance type or -1 when not set. +int NWNX_Appearance_GetOverride(object oPlayer, object oCreature, int nType); + +/// @} + +void NWNX_Appearance_SetOverride(object oPlayer, object oCreature, int nType, int nValue) +{ + string sFunc = "SetOverride"; + + NWNX_PushArgumentInt(NWNX_Appearance, sFunc, nValue); + NWNX_PushArgumentInt(NWNX_Appearance, sFunc, nType); + NWNX_PushArgumentObject(NWNX_Appearance, sFunc, oCreature); + NWNX_PushArgumentObject(NWNX_Appearance, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Appearance, sFunc); +} + +int NWNX_Appearance_GetOverride(object oPlayer, object oCreature, int nType) +{ + string sFunc = "GetOverride"; + + NWNX_PushArgumentInt(NWNX_Appearance, sFunc, nType); + NWNX_PushArgumentObject(NWNX_Appearance, sFunc, oCreature); + NWNX_PushArgumentObject(NWNX_Appearance, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Appearance, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Appearance, sFunc); +} diff --git a/nwnds_module/nwnx_area.nss b/nwnds_module/nwnx_area.nss new file mode 100644 index 000000000..f1a9134ff --- /dev/null +++ b/nwnds_module/nwnx_area.nss @@ -0,0 +1,660 @@ +/// @addtogroup area Area +/// @brief Functions exposing additional area properties as well as creating transitions. +/// @{ +/// @file nwnx_area.nss +#include "nwnx" + +const string NWNX_Area = "NWNX_Area"; ///< @private + +/// @name Area PVP Settings +/// @anchor area_pvp +/// @{ +const int NWNX_AREA_PVP_SETTING_NO_PVP = 0; +const int NWNX_AREA_PVP_SETTING_PARTY_PVP = 1; +const int NWNX_AREA_PVP_SETTING_FULL_PVP = 2; +const int NWNX_AREA_PVP_SETTING_SERVER_DEFAULT = 3; +/// @} + +/// @name Area Weather Settings +/// @anchor area_weather +/// @{ +const int NWNX_AREA_WEATHER_CHANCE_RAIN = 0; +const int NWNX_AREA_WEATHER_CHANCE_SNOW = 1; +const int NWNX_AREA_WEATHER_CHANCE_LIGHTNING = 2; +/// @} + +/// @name Area Day Night Cycle Settings +/// @anchor area_daynight +/// @{ +const int NWNX_AREA_DAYNIGHTCYCLE_CYCLE_DAY_NIGHT = 0; +const int NWNX_AREA_DAYNIGHTCYCLE_ALWAYS_BRIGHT = 1; +const int NWNX_AREA_DAYNIGHTCYCLE_ALWAYS_DARK = 2; +/// @} + +/// @name Area Sun/Moon Color Settings +/// @anchor area_color +/// @{ +const int NWNX_AREA_COLOR_TYPE_MOON_AMBIENT = 0; +const int NWNX_AREA_COLOR_TYPE_MOON_DIFFUSE = 1; +const int NWNX_AREA_COLOR_TYPE_SUN_AMBIENT = 2; +const int NWNX_AREA_COLOR_TYPE_SUN_DIFFUSE = 3; +/// @} + +/// @brief A tile info struct +struct NWNX_Area_TileInfo +{ + int nID; ///< The tile's ID + int nHeight; ///< The tile's height + int nOrientation; ///< The tile's orientation + int nGridX; ///< The tile's grid x position + int nGridY; ///< The tile's grid y position +}; + +/// @brief Gets the number of players in area. +/// @param area The area object. +/// @return The player count for the area. +int NWNX_Area_GetNumberOfPlayersInArea(object area); + +/// @brief Gets the creature that last entered area. +/// @param area The area object. +/// @return The most recent creature to enter the area. +object NWNX_Area_GetLastEntered(object area); + +/// @brief Gets the creature that last left area +/// @param area The area object. +object NWNX_Area_GetLastLeft(object area); + +/// @brief Get the PVP setting of area +/// @param area The area object. +/// @return Returns the @ref area_pvp "PVP Setting" for the area. +int NWNX_Area_GetPVPSetting(object area); + +/// @brief Set the PVP setting of area +/// @param area The area object. +/// @param pvpSetting One of @ref area_pvp the "PVP Settings". +void NWNX_Area_SetPVPSetting(object area, int pvpSetting); + +/// @brief Get the spot modifier of area +/// @param area The area object. +/// @return The value of the Spot skill modifier for this area. +int NWNX_Area_GetAreaSpotModifier(object area); + +/// @brief Set the spot modifier of area +/// @param area The area object. +/// @param spotModifier The modifier to the Spot skill for this area. +/// @sa NWNX_SkillRanks_SetAreaModifier() to change any skill modifier. +void NWNX_Area_SetAreaSpotModifier(object area, int spotModifier); + +/// @brief Get the listen modifer of area +/// @param area The area object. +/// @return The value of the Listen skill modifier for this area. +int NWNX_Area_GetAreaListenModifier(object area); + +/// @brief Set the listen modifier of area +/// @param area The area object. +/// @param listenModifier The modifier to the Listen skill for this area. +/// @sa NWNX_SkillRanks_SetAreaModifier() to change any skill modifier. +void NWNX_Area_SetAreaListenModifier(object area, int listenModifier); + +/// @brief Checks the No Resting area flag +/// @param area The area object. +/// @return TRUE if resting is not allowed in area. +int NWNX_Area_GetNoRestingAllowed(object area); + +/// @brief Set whether to disable resting in the area. +/// @param area The area object. +/// @param bNoRestingAllowed TRUE to disable resting in the area. +void NWNX_Area_SetNoRestingAllowed(object area, int bNoRestingAllowed); + +/// @brief Get the wind power in area +/// @param area The area object. +/// @return The wind power for the area. (0-2) +int NWNX_Area_GetWindPower(object area); + +/// @brief Set the wind power in area +/// @param area The area object. +/// @param windPower Set to 0, 1 or 2. +void NWNX_Area_SetWindPower(object area, int windPower); + +/// @brief Get the weather chance of type in area +/// @param type A @ref area_weather "Weather Setting". +/// @param area The area object. +/// @return The percentage chance for the weather type. (0-100) +int NWNX_Area_GetWeatherChance(object area, int type); + +/// @brief Set the weather chance of type in area +/// @param area The area object. +/// @param type A @ref area_weather "Weather Setting". +/// @param chance The chance this weather event occurs. +void NWNX_Area_SetWeatherChance(object area, int type, int chance); + +/// @brief Get the fog clip distance in area +/// @param area The area object. +/// @return The fog clip distance. +float NWNX_Area_GetFogClipDistance(object area); + +/// @brief Set the fog clip distance in area +/// @param area The area object. +/// @param distance The new fog clip distance. +void NWNX_Area_SetFogClipDistance(object area, float distance); + +/// @brief Get the shadow opacity of area +/// @param area The area object. +/// @return The shadow opacity for the area. (0-100) +int NWNX_Area_GetShadowOpacity(object area); + +/// @brief Set the shadow opacity of area +/// @param area The area object. +/// @param shadowOpacity The shadow opacity to set for the area (0-100). +void NWNX_Area_SetShadowOpacity(object area, int shadowOpacity); + +/// @brief Get the day/night cycle of area +/// @param area The area object. +/// @return The @ref area_daynight "Day Night Cycle Setting". +int NWNX_Area_GetDayNightCycle(object area); + +/// @brief Set the day/night cycle of area +/// @param area The area object. +/// @param type = A @ref area_daynight "Day Night Cycle Setting". +void NWNX_Area_SetDayNightCycle(object area, int type); + +/// @brief Get the Sun/Moon Ambient/Diffuse colors of area +/// @param area The area object. +/// @param type = A @ref area_color "Sun/Moon Color Setting". +/// @return A FOG_COLOR_* or a custom value, -1 on error. +int NWNX_Area_GetSunMoonColors(object area, int type); + +/// @brief Set the Sun/Moon Ambient/Diffuse colors of area +// type = NWNX_AREA_COLOR_TYPE_* +/// @param area The area object. +/// @param type = A @ref area_color "Sun/Moon Color Setting". +/// @param color = A FOG_COLOR_*. +/// @note The color can also be represented as a hex RGB number if specific color shades are desired. +/// The format of a hex specified color would be 0xFFEEDD where +/// * FF would represent the amount of red in the color +/// * EE would represent the amount of green in the color +/// * DD would represent the amount of blue in the color. +void NWNX_Area_SetSunMoonColors(object area, int type, int color); + +/// @brief Create and returns a transition (square shaped of specified size) at a location. +/// @param area The area object. +/// @param target A door or waypoint object. +/// @param x,y,z The position to create the transition. +/// @param size The size of the square. +/// @param tag If specified, the returning object will have this tag. +/// @sa NWNX_Object_SetTriggerGeometry() if you wish to draw the transition as something other than a square. +object NWNX_Area_CreateTransition(object area, object target, float x, float y, float z, float size = 2.0f, string tag=""); + +/// @brief Get the state of a tile animation loop. +/// @param oArea The area object. +/// @param fTileX, fTileY The coordinates of the tile. +/// @param nAnimLoop The loop to check. (1-3) +/// @return TRUE if the loop is enabled. +int NWNX_Area_GetTileAnimationLoop(object oArea, float fTileX, float fTileY, int nAnimLoop); + +/// @brief Set the state of a tile animation loop. +/// @param oArea The area object. +/// @param fTileX, fTileY The coordinates of the tile. +/// @param nAnimLoop The loop to set (1-3). +/// @param bEnabled TRUE or FALSE. +/// @note Requires clients to re-enter the area for it to take effect +void NWNX_Area_SetTileAnimationLoop(object oArea, float fTileX, float fTileY, int nAnimLoop, int bEnabled); + +/// @brief Get the name of the tile model from any location. +/// @param oArea The area name. +/// @param fTileX, fTileY The coordinates of the tile. +string NWNX_Area_GetTileModelResRef(object oArea, float fTileX, float fTileY); + +/// @brief Test to see if there's a direct, walkable line between two points in the area. +/// @param oArea The area object. +/// @param fStartX, fStartY The starting points. +/// @param fEndX, fEndY The ending points. +/// @param fPerSpace The personal space of a creature. Found in appearance.2da. +/// @param fHeight The height of a creature. Found in appearance.2da. +/// @param bIgnoreDoors Whether to ignore doors in the check. +/// @return +/// * 1 if there is a direct walkable line. +/// * -1 if the line is blocked by terrain. +/// * -2 if the line is blocked by a placeable. +/// * -3 if the line is blocked by a creature. +int NWNX_Area_TestDirectLine(object oArea, float fStartX, float fStartY, float fEndX, float fEndY, float fPerSpace, float fHeight, int bIgnoreDoors=FALSE); + +/// @brief Get if the area music is playing. +/// @param oArea The area object. +/// @param bBattleMusic Set to TRUE to get if the battle music is playing. +/// @return TRUE if music is playing +int NWNX_Area_GetMusicIsPlaying(object oArea, int bBattleMusic = FALSE); + +/// @brief Create and return a generic trigger (square shaped of specified size) at a location. +/// @param oArea The area object. +/// @param fX, fY, fZ The position to create the trigger. +/// @param sTag If specified, the returned trigger will have this tag. +/// @param fSize The size of the square. +/// @sa NWNX_Object_SetTriggerGeometry() if you wish to draw the trigger as something other than a square. +object NWNX_Area_CreateGenericTrigger(object oArea, float fX, float fY, float fZ, string sTag = "", float fSize = 1.0f); + +/// @brief Add oObject to the ExportGIT exclusion list, objects on this list won't be exported when NWNX_Area_ExportGIT() is called. +/// @param oObject The object to add +void NWNX_Area_AddObjectToExclusionList(object oObject); + +/// @brief Remove oObject from the ExportGIT exclusion list. +/// @param oObject The object to add +void NWNX_Area_RemoveObjectFromExclusionList(object oObject); + +/// @brief Export the .git file of oArea to the UserDirectory/nwnx folder, or to the location of sAlias. +/// @note Take care with local objects set on objects, they will likely not reference the same object after a server restart. +/// @param oArea The area to export the .git file of. +/// @param sFileName The filename, 16 characters or less and should be lowercase. If left blank the resref of oArea will be used. +/// @param bExportVarTable If TRUE, local variables set on oArea will be exported too. +/// @param bExportUUID If TRUE, the UUID of oArea will be exported, if it has one. +/// @param nObjectFilter One or more OBJECT_TYPE_* constants. These object will not be exported. For example OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR +/// will not export creatures and doors. Use OBJECT_TYPE_ALL to filter all objects or 0 to export all objects. +/// @param sAlias The alias of the resource directory to add the .git file to. Default: UserDirectory/nwnx +/// @return TRUE if exported successfully, FALSE if not. +int NWNX_Area_ExportGIT(object oArea, string sFileName = "", int bExportVarTable = TRUE, int bExportUUID = TRUE, int nObjectFilter = 0, string sAlias = "NWNX"); + +/// @brief Get the tile info of the tile at [fTileX, fTileY] in oArea. +/// @param oArea The area name. +/// @param fTileX, fTileY The coordinates of the tile. +/// @return A NWNX_Area_TileInfo struct with tile info. +struct NWNX_Area_TileInfo NWNX_Area_GetTileInfo(object oArea, float fTileX, float fTileY); + +/// @brief Export the .are file of oArea to the UserDirectory/nwnx folder, or to the location of sAlias. +/// @param oArea The area to export the .are file of. +/// @param sFileName The filename, 16 characters or less and should be lowercase. This will also be the resref of the area. +/// @param sNewName Optional new name of the area. Leave blank to use the current name. +/// @param sNewTag Optional new tag of the area. Leave blank to use the current tag. +/// @param sAlias The alias of the resource directory to add the .are file to. Default: UserDirectory/nwnx +/// @return TRUE if exported successfully, FALSE if not. +int NWNX_Area_ExportARE(object oArea, string sFileName, string sNewName = "", string sNewTag = "", string sAlias = "NWNX"); + +/// @} + +int NWNX_Area_GetNumberOfPlayersInArea(object area) +{ + string sFunc = "GetNumberOfPlayersInArea"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +object NWNX_Area_GetLastEntered(object area) +{ + string sFunc = "GetLastEntered"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Area, sFunc); +} + +object NWNX_Area_GetLastLeft(object area) +{ + string sFunc = "GetLastLeft"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Area, sFunc); +} + +int NWNX_Area_GetPVPSetting(object area) +{ + string sFunc = "GetPVPSetting"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetPVPSetting(object area, int pvpSetting) +{ + string sFunc = "SetPVPSetting"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, pvpSetting); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetAreaSpotModifier(object area) +{ + string sFunc = "GetAreaSpotModifier"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetAreaSpotModifier(object area, int spotModifier) +{ + string sFunc = "SetAreaSpotModifier"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, spotModifier); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetAreaListenModifier(object area) +{ + string sFunc = "GetAreaListenModifier"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetAreaListenModifier(object area, int listenModifier) +{ + string sFunc = "SetAreaListenModifier"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, listenModifier); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetNoRestingAllowed(object area) +{ + string sFunc = "GetNoRestingAllowed"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetNoRestingAllowed(object area, int bNoRestingAllowed) +{ + string sFunc = "SetNoRestingAllowed"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, bNoRestingAllowed); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetWindPower(object area) +{ + string sFunc = "GetWindPower"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetWindPower(object area, int windPower) +{ + string sFunc = "SetWindPower"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, windPower); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetWeatherChance(object area, int type) +{ + string sFunc = "GetWeatherChance"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, type); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetWeatherChance(object area, int type, int chance) +{ + string sFunc = "SetWeatherChance"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, chance); + NWNX_PushArgumentInt(NWNX_Area, sFunc, type); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +float NWNX_Area_GetFogClipDistance(object area) +{ + string sFunc = "GetFogClipDistance"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueFloat(NWNX_Area, sFunc); +} + +void NWNX_Area_SetFogClipDistance(object area, float distance) +{ + string sFunc = "SetFogClipDistance"; + + NWNX_PushArgumentFloat(NWNX_Area, sFunc, distance); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetShadowOpacity(object area) +{ + string sFunc = "GetShadowOpacity"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetShadowOpacity(object area, int shadowOpacity) +{ + string sFunc = "SetShadowOpacity"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, shadowOpacity); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + + +int NWNX_Area_GetDayNightCycle(object area) +{ + string sFunc = "GetDayNightCycle"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetDayNightCycle(object area, int type) +{ + string sFunc = "SetDayNightCycle"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, type); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_GetSunMoonColors(object area, int type) +{ + string sFunc = "GetSunMoonColors"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, type); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetSunMoonColors(object area, int type, int color) +{ + string sFunc = "SetSunMoonColors"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, color); + NWNX_PushArgumentInt(NWNX_Area, sFunc, type); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +object NWNX_Area_CreateTransition(object area, object target, float x, float y, float z, float size = 2.0f, string tag="") +{ + string sFunc = "CreateTransition"; + + NWNX_PushArgumentString(NWNX_Area, sFunc, tag); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, size); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, z); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, y); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, x); + NWNX_PushArgumentObject(NWNX_Area, sFunc, target); + NWNX_PushArgumentObject(NWNX_Area, sFunc, area); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Area, sFunc); +} + +int NWNX_Area_GetTileAnimationLoop(object oArea, float fTileX, float fTileY, int nAnimLoop) +{ + string sFunc = "GetTileAnimationLoop"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, nAnimLoop); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +void NWNX_Area_SetTileAnimationLoop(object oArea, float fTileX, float fTileY, int nAnimLoop, int bEnabled) +{ + string sFunc = "SetTileAnimationLoop"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, bEnabled); + NWNX_PushArgumentInt(NWNX_Area, sFunc, nAnimLoop); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + + NWNX_CallFunction(NWNX_Area, sFunc); +} + +string NWNX_Area_GetTileModelResRef(object oArea, float fTileX, float fTileY) +{ + string sFunc = "GetTileModelResRef"; + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueString(NWNX_Area, sFunc); +} + +int NWNX_Area_TestDirectLine(object oArea, float fStartX, float fStartY, float fEndX, float fEndY, float fPerSpace, float fHeight, int bIgnoreDoors=FALSE) +{ + string sFunc = "TestDirectLine"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, bIgnoreDoors); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fHeight); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fPerSpace); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fEndY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fEndX); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fStartY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fStartX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +int NWNX_Area_GetMusicIsPlaying(object oArea, int bBattleMusic = FALSE) +{ + string sFunc = "GetMusicIsPlaying"; + + NWNX_PushArgumentInt(NWNX_Area, sFunc, bBattleMusic); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +object NWNX_Area_CreateGenericTrigger(object oArea, float fX, float fY, float fZ, string sTag = "", float fSize = 1.0f) +{ + string sFunc = "CreateGenericTrigger"; + + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fSize); + NWNX_PushArgumentString(NWNX_Area, sFunc, sTag); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fZ); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Area, sFunc); +} + +void NWNX_Area_AddObjectToExclusionList(object oObject) +{ + string sFunc = "AddObjectToExclusionList"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, oObject); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +void NWNX_Area_RemoveObjectFromExclusionList(object oObject) +{ + string sFunc = "RemoveObjectFromExclusionList"; + + NWNX_PushArgumentObject(NWNX_Area, sFunc, oObject); + NWNX_CallFunction(NWNX_Area, sFunc); +} + +int NWNX_Area_ExportGIT(object oArea, string sFileName = "", int bExportVarTable = TRUE, int bExportUUID = TRUE, int nObjectFilter = 0, string sAlias = "NWNX") +{ + string sFunc = "ExportGIT"; + + NWNX_PushArgumentString(NWNX_Area, sFunc, sAlias); + NWNX_PushArgumentInt(NWNX_Area, sFunc, nObjectFilter); + NWNX_PushArgumentInt(NWNX_Area, sFunc, bExportUUID); + NWNX_PushArgumentInt(NWNX_Area, sFunc, bExportVarTable); + NWNX_PushArgumentString(NWNX_Area, sFunc, sFileName); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} + +struct NWNX_Area_TileInfo NWNX_Area_GetTileInfo(object oArea, float fTileX, float fTileY) +{ + string sFunc = "GetTileInfo"; + + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileY); + NWNX_PushArgumentFloat(NWNX_Area, sFunc, fTileX); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + NWNX_CallFunction(NWNX_Area, sFunc); + + struct NWNX_Area_TileInfo str; + + str.nGridY = NWNX_GetReturnValueInt(NWNX_Area, sFunc); + str.nGridX = NWNX_GetReturnValueInt(NWNX_Area, sFunc); + str.nOrientation = NWNX_GetReturnValueInt(NWNX_Area, sFunc); + str.nHeight = NWNX_GetReturnValueInt(NWNX_Area, sFunc); + str.nID = NWNX_GetReturnValueInt(NWNX_Area, sFunc); + + return str; +} + +int NWNX_Area_ExportARE(object oArea, string sFileName, string sNewName = "", string sNewTag = "", string sAlias = "NWNX") +{ + string sFunc = "ExportARE"; + + NWNX_PushArgumentString(NWNX_Area, sFunc, sAlias); + NWNX_PushArgumentString(NWNX_Area, sFunc, sNewTag); + NWNX_PushArgumentString(NWNX_Area, sFunc, sNewName); + NWNX_PushArgumentString(NWNX_Area, sFunc, sFileName); + NWNX_PushArgumentObject(NWNX_Area, sFunc, oArea); + NWNX_CallFunction(NWNX_Area, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Area, sFunc); +} diff --git a/nwnds_module/nwnx_chat.nss b/nwnds_module/nwnx_chat.nss new file mode 100644 index 000000000..90ca95e49 --- /dev/null +++ b/nwnds_module/nwnx_chat.nss @@ -0,0 +1,158 @@ +/// @addtogroup chat Chat +/// @brief Functions related to chat. +/// @{ +/// @file nwnx_chat.nss +#include "nwnx" + +const string NWNX_Chat = "NWNX_Chat"; ///< @private + +/// @name Chat Channels +/// @anchor chat_channels +/// +/// Constants defining the various chat channels. +/// @{ +const int NWNX_CHAT_CHANNEL_PLAYER_TALK = 1; +const int NWNX_CHAT_CHANNEL_PLAYER_SHOUT = 2; +const int NWNX_CHAT_CHANNEL_PLAYER_WHISPER = 3; +const int NWNX_CHAT_CHANNEL_PLAYER_TELL = 4; +const int NWNX_CHAT_CHANNEL_SERVER_MSG = 5; +const int NWNX_CHAT_CHANNEL_PLAYER_PARTY = 6; +const int NWNX_CHAT_CHANNEL_PLAYER_DM = 14; +const int NWNX_CHAT_CHANNEL_DM_TALK = 17; +const int NWNX_CHAT_CHANNEL_DM_SHOUT = 18; +const int NWNX_CHAT_CHANNEL_DM_WHISPER = 19; +const int NWNX_CHAT_CHANNEL_DM_TELL = 20; +const int NWNX_CHAT_CHANNEL_DM_PARTY = 22; +const int NWNX_CHAT_CHANNEL_DM_DM = 30; +/// @} + +/// @brief Sends a chat message. +/// @remark If no target is provided, then it broadcasts to all eligible targets. +/// @param channel The @ref chat_channels "channel" to send the message. +/// @param message The message to send. +/// @param sender The sender of the message. +/// @param target The receiver of the message. +/// @return TRUE if successful, FALSE otherwise. +int NWNX_Chat_SendMessage(int channel, string message, object sender = OBJECT_SELF, object target = OBJECT_INVALID); + +/// @brief Registers the script which receives all chat messages. +/// @note If a script was previously registered, this one will take over. +/// @param script The script name to handle the chat events. +void NWNX_Chat_RegisterChatScript(string script); + +/// @brief Skips a chat message +/// @note Must be called from a chat or system script handler. +void NWNX_Chat_SkipMessage(); + +/// @brief Gets the chat @ref chat_channels "channel". +/// @note Must be called from a chat or system script handler. +/// @return The @ref chat_channels "channel" the message is sent. +int NWNX_Chat_GetChannel(); + +/// @brief Gets the message. +/// @note Must be called from a chat or system script handler. +/// @return The message sent. +string NWNX_Chat_GetMessage(); + +/// @brief Gets the sender of the message. +/// @note Must be called from a chat or system script handler. +/// @return The object sending the message. +object NWNX_Chat_GetSender(); + +/// @brief Gets the target of the message. +/// @note Must be called from an chat or system script handler. +/// @return The target of the message or OBJECT_INVALID if no target. +object NWNX_Chat_GetTarget(); + +/// @brief Sets the distance with which the player hears talks or whispers. +/// @remark Per player settings override server wide. +/// @param distance The distance in meters. +/// @param listener The listener, if OBJECT_INVALID then it will be set server wide. +/// @param channel The @ref chat_channels "channel" to modify the distance heard. Only applicable for talk and whisper. +void NWNX_Chat_SetChatHearingDistance(float distance, object listener = OBJECT_INVALID, int channel = NWNX_CHAT_CHANNEL_PLAYER_TALK); + +/// @brief Gets the distance with which the player hears talks or whisper +/// @param listener The listener, if OBJECT_INVALID then will return server wide setting. +/// @param channel The @ref chat_channels "channel". Only applicable for talk and whisper. +float NWNX_Chat_GetChatHearingDistance(object listener = OBJECT_INVALID, int channel = NWNX_CHAT_CHANNEL_PLAYER_TALK); + +/// @} + +int NWNX_Chat_SendMessage(int channel, string message, object sender = OBJECT_SELF, object target = OBJECT_INVALID) +{ + string sFunc = "SendMessage"; + + NWNX_PushArgumentObject(NWNX_Chat, sFunc, target); + NWNX_PushArgumentObject(NWNX_Chat, sFunc, sender); + NWNX_PushArgumentString(NWNX_Chat, sFunc, message); + NWNX_PushArgumentInt(NWNX_Chat, sFunc, channel); + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueInt(NWNX_Chat, sFunc); +} + +void NWNX_Chat_RegisterChatScript(string script) +{ + string sFunc = "RegisterChatScript"; + + NWNX_PushArgumentString(NWNX_Chat, sFunc, script); + NWNX_CallFunction(NWNX_Chat, sFunc); +} + +void NWNX_Chat_SkipMessage() +{ + string sFunc = "SkipMessage"; + + NWNX_CallFunction(NWNX_Chat, sFunc); +} + +int NWNX_Chat_GetChannel() +{ + string sFunc = "GetChannel"; + + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueInt(NWNX_Chat, sFunc); +} + +string NWNX_Chat_GetMessage() +{ + string sFunc = "GetMessage"; + + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueString(NWNX_Chat, sFunc); +} + +object NWNX_Chat_GetSender() +{ + string sFunc = "GetSender"; + + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueObject(NWNX_Chat, sFunc); +} + +object NWNX_Chat_GetTarget() +{ + string sFunc = "GetTarget"; + + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueObject(NWNX_Chat, sFunc); +} + +void NWNX_Chat_SetChatHearingDistance(float distance, object listener = OBJECT_INVALID, int channel = NWNX_CHAT_CHANNEL_PLAYER_TALK) +{ + string sFunc = "SetChatHearingDistance"; + + NWNX_PushArgumentInt(NWNX_Chat, sFunc, channel); + NWNX_PushArgumentObject(NWNX_Chat, sFunc, listener); + NWNX_PushArgumentFloat(NWNX_Chat, sFunc, distance); + NWNX_CallFunction(NWNX_Chat, sFunc); +} + +float NWNX_Chat_GetChatHearingDistance(object listener = OBJECT_INVALID, int channel = NWNX_CHAT_CHANNEL_PLAYER_TALK) +{ + string sFunc = "GetChatHearingDistance"; + + NWNX_PushArgumentInt(NWNX_Chat, sFunc, channel); + NWNX_PushArgumentObject(NWNX_Chat, sFunc, listener); + NWNX_CallFunction(NWNX_Chat, sFunc); + return NWNX_GetReturnValueFloat(NWNX_Chat, sFunc); +} diff --git a/nwnds_module/nwnx_consts.nss b/nwnds_module/nwnx_consts.nss new file mode 100644 index 000000000..3562ec79b --- /dev/null +++ b/nwnds_module/nwnx_consts.nss @@ -0,0 +1,182 @@ +/// @ingroup nwnx +/// @addtogroup consts NWNX Constants +/// @brief Provides various NWScript <-> Engine Constants Translation Table functions +/// @{ +/// @file nwnx_consts.nss + +/// @brief Translates ANIMATION_LOOPING_* and ANIMATION_FIREFORGET_* constants to their engine equivalent. +/// @param nAnimation The nwn animation constant +/// @return The engine equivalent of the constant +int NWNX_Consts_TranslateNWScriptAnimation(int nAnimation); + +/// @brief Translates engine animation constants to their ANIMATION_LOOPING_* and ANIMATION_FIREFORGET_* equivalent. +/// @param nAnimation The engine animation constant +/// @return The NWScript equivalent of the constant or -1 if a nwscript equivalent doesn't exist +int NWNX_Consts_TranslateEngineAnimation(int nAnimation); + +/// @brief Translates OBJECT_TYPE_* constants to their engine equivalent. +/// @param nObjectType The nwn object type +/// @return The engine equivalent of the constant +int NWNX_Consts_TranslateNWScriptObjectType(int nObjectType); + + +int NWNX_Consts_TranslateNWScriptAnimation(int nAnimation) +{ + switch (nAnimation) + { + case ANIMATION_LOOPING_PAUSE: nAnimation = 0; break; + case ANIMATION_LOOPING_PAUSE2: nAnimation = 52; break; + case ANIMATION_LOOPING_LISTEN: nAnimation = 30; break; + case ANIMATION_LOOPING_MEDITATE: nAnimation = 32; break; + case ANIMATION_LOOPING_WORSHIP: nAnimation = 33; break; + case ANIMATION_LOOPING_LOOK_FAR: nAnimation = 48; break; + case ANIMATION_LOOPING_SIT_CHAIR: nAnimation = 36; break; + case ANIMATION_LOOPING_SIT_CROSS: nAnimation = 47; break; + case ANIMATION_LOOPING_TALK_NORMAL: nAnimation = 38; break; + case ANIMATION_LOOPING_TALK_PLEADING: nAnimation = 39; break; + case ANIMATION_LOOPING_TALK_FORCEFUL: nAnimation = 40; break; + case ANIMATION_LOOPING_TALK_LAUGHING: nAnimation = 41; break; + case ANIMATION_LOOPING_GET_LOW: nAnimation = 59; break; + case ANIMATION_LOOPING_GET_MID: nAnimation = 60; break; + case ANIMATION_LOOPING_PAUSE_TIRED: nAnimation = 57; break; + case ANIMATION_LOOPING_PAUSE_DRUNK: nAnimation = 58; break; + case ANIMATION_LOOPING_DEAD_FRONT: nAnimation = 6; break; + case ANIMATION_LOOPING_DEAD_BACK: nAnimation = 8; break; + case ANIMATION_LOOPING_CONJURE1: nAnimation = 15; break; + case ANIMATION_LOOPING_CONJURE2: nAnimation = 16; break; + case ANIMATION_LOOPING_SPASM: nAnimation = 93; break; + case ANIMATION_LOOPING_CUSTOM1: nAnimation = 97; break; + case ANIMATION_LOOPING_CUSTOM2: nAnimation = 98; break; + case ANIMATION_LOOPING_CUSTOM3: nAnimation = 101; break; + case ANIMATION_LOOPING_CUSTOM4: nAnimation = 102; break; + case ANIMATION_LOOPING_CUSTOM5: nAnimation = 103; break; + case ANIMATION_LOOPING_CUSTOM6: nAnimation = 104; break; + case ANIMATION_LOOPING_CUSTOM7: nAnimation = 105; break; + case ANIMATION_LOOPING_CUSTOM8: nAnimation = 106; break; + case ANIMATION_LOOPING_CUSTOM9: nAnimation = 107; break; + case ANIMATION_LOOPING_CUSTOM10: nAnimation = 108; break; + case ANIMATION_LOOPING_CUSTOM11: nAnimation = 109; break; + case ANIMATION_LOOPING_CUSTOM12: nAnimation = 110; break; + case ANIMATION_LOOPING_CUSTOM13: nAnimation = 111; break; + case ANIMATION_LOOPING_CUSTOM14: nAnimation = 112; break; + case ANIMATION_LOOPING_CUSTOM15: nAnimation = 113; break; + case ANIMATION_LOOPING_CUSTOM16: nAnimation = 114; break; + case ANIMATION_LOOPING_CUSTOM17: nAnimation = 115; break; + case ANIMATION_LOOPING_CUSTOM18: nAnimation = 116; break; + case ANIMATION_LOOPING_CUSTOM19: nAnimation = 117; break; + case ANIMATION_LOOPING_CUSTOM20: nAnimation = 118; break; + case ANIMATION_MOUNT1: nAnimation = 119; break; + case ANIMATION_DISMOUNT1: nAnimation = 120; break; + case ANIMATION_FIREFORGET_HEAD_TURN_LEFT: nAnimation = 53; break; + case ANIMATION_FIREFORGET_HEAD_TURN_RIGHT: nAnimation = 54; break; + case ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD: nAnimation = 55; break; + case ANIMATION_FIREFORGET_PAUSE_BORED: nAnimation = 56; break; + case ANIMATION_FIREFORGET_SALUTE: nAnimation = 34; break; + case ANIMATION_FIREFORGET_BOW: nAnimation = 35; break; + case ANIMATION_FIREFORGET_STEAL: nAnimation = 37; break; + case ANIMATION_FIREFORGET_GREETING: nAnimation = 29; break; + case ANIMATION_FIREFORGET_TAUNT: nAnimation = 28; break; + case ANIMATION_FIREFORGET_VICTORY1: nAnimation = 44; break; + case ANIMATION_FIREFORGET_VICTORY2: nAnimation = 45; break; + case ANIMATION_FIREFORGET_VICTORY3: nAnimation = 46; break; + case ANIMATION_FIREFORGET_READ: nAnimation = 71; break; + case ANIMATION_FIREFORGET_DRINK: nAnimation = 70; break; + case ANIMATION_FIREFORGET_DODGE_SIDE: nAnimation = 90; break; + case ANIMATION_FIREFORGET_DODGE_DUCK: nAnimation = 91; break; + case ANIMATION_FIREFORGET_SPASM: nAnimation = 23; break; + default: nAnimation = 0; break; + } + + return nAnimation; +} + +int NWNX_Consts_TranslateEngineAnimation(int nAnimation) +{ + switch (nAnimation) + { + case 0: nAnimation = ANIMATION_LOOPING_PAUSE; break; + case 52: nAnimation = ANIMATION_LOOPING_PAUSE2; break; + case 30: nAnimation = ANIMATION_LOOPING_LISTEN; break; + case 32: nAnimation = ANIMATION_LOOPING_MEDITATE; break; + case 33: nAnimation = ANIMATION_LOOPING_WORSHIP; break; + case 48: nAnimation = ANIMATION_LOOPING_LOOK_FAR; break; + case 36: nAnimation = ANIMATION_LOOPING_SIT_CHAIR; break; + case 47: nAnimation = ANIMATION_LOOPING_SIT_CROSS; break; + case 38: nAnimation = ANIMATION_LOOPING_TALK_NORMAL; break; + case 39: nAnimation = ANIMATION_LOOPING_TALK_PLEADING; break; + case 40: nAnimation = ANIMATION_LOOPING_TALK_FORCEFUL; break; + case 41: nAnimation = ANIMATION_LOOPING_TALK_LAUGHING; break; + case 59: nAnimation = ANIMATION_LOOPING_GET_LOW; break; + case 60: nAnimation = ANIMATION_LOOPING_GET_MID; break; + case 57: nAnimation = ANIMATION_LOOPING_PAUSE_TIRED; break; + case 58: nAnimation = ANIMATION_LOOPING_PAUSE_DRUNK; break; + case 6: nAnimation = ANIMATION_LOOPING_DEAD_FRONT; break; + case 8: nAnimation = ANIMATION_LOOPING_DEAD_BACK; break; + case 15: nAnimation = ANIMATION_LOOPING_CONJURE1; break; + case 16: nAnimation = ANIMATION_LOOPING_CONJURE2; break; + case 93: nAnimation = ANIMATION_LOOPING_SPASM; break; + case 97: nAnimation = ANIMATION_LOOPING_CUSTOM1; break; + case 98: nAnimation = ANIMATION_LOOPING_CUSTOM2; break; + case 101: nAnimation = ANIMATION_LOOPING_CUSTOM3; break; + case 102: nAnimation = ANIMATION_LOOPING_CUSTOM4; break; + case 103: nAnimation = ANIMATION_LOOPING_CUSTOM5; break; + case 104: nAnimation = ANIMATION_LOOPING_CUSTOM6; break; + case 105: nAnimation = ANIMATION_LOOPING_CUSTOM7; break; + case 106: nAnimation = ANIMATION_LOOPING_CUSTOM8; break; + case 107: nAnimation = ANIMATION_LOOPING_CUSTOM9; break; + case 108: nAnimation = ANIMATION_LOOPING_CUSTOM10; break; + case 109: nAnimation = ANIMATION_LOOPING_CUSTOM11; break; + case 110: nAnimation = ANIMATION_LOOPING_CUSTOM12; break; + case 111: nAnimation = ANIMATION_LOOPING_CUSTOM13; break; + case 112: nAnimation = ANIMATION_LOOPING_CUSTOM14; break; + case 113: nAnimation = ANIMATION_LOOPING_CUSTOM15; break; + case 114: nAnimation = ANIMATION_LOOPING_CUSTOM16; break; + case 115: nAnimation = ANIMATION_LOOPING_CUSTOM17; break; + case 116: nAnimation = ANIMATION_LOOPING_CUSTOM18; break; + case 117: nAnimation = ANIMATION_LOOPING_CUSTOM19; break; + case 118: nAnimation = ANIMATION_LOOPING_CUSTOM20; break; + case 119: nAnimation = ANIMATION_MOUNT1; break; + case 120: nAnimation = ANIMATION_DISMOUNT1; break; + case 53: nAnimation = ANIMATION_FIREFORGET_HEAD_TURN_LEFT; break; + case 54: nAnimation = ANIMATION_FIREFORGET_HEAD_TURN_RIGHT; break; + case 55: nAnimation = ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD; break; + case 56: nAnimation = ANIMATION_FIREFORGET_PAUSE_BORED; break; + case 34: nAnimation = ANIMATION_FIREFORGET_SALUTE; break; + case 35: nAnimation = ANIMATION_FIREFORGET_BOW; break; + case 37: nAnimation = ANIMATION_FIREFORGET_STEAL; break; + case 29: nAnimation = ANIMATION_FIREFORGET_GREETING; break; + case 28: nAnimation = ANIMATION_FIREFORGET_TAUNT; break; + case 44: nAnimation = ANIMATION_FIREFORGET_VICTORY1; break; + case 45: nAnimation = ANIMATION_FIREFORGET_VICTORY2; break; + case 46: nAnimation = ANIMATION_FIREFORGET_VICTORY3; break; + case 71: nAnimation = ANIMATION_FIREFORGET_READ; break; + case 70: nAnimation = ANIMATION_FIREFORGET_DRINK; break; + case 90: nAnimation = ANIMATION_FIREFORGET_DODGE_SIDE; break; + case 91: nAnimation = ANIMATION_FIREFORGET_DODGE_DUCK; break; + case 23: nAnimation = ANIMATION_FIREFORGET_SPASM; break; + default: nAnimation = -1; break; + } + + return nAnimation; +} + +int NWNX_Consts_TranslateNWScriptObjectType(int nObjectType) +{ + switch(nObjectType) + { + case OBJECT_TYPE_ALL: nObjectType = 0; break; + case OBJECT_TYPE_AREA_OF_EFFECT: nObjectType = 11; break; + case OBJECT_TYPE_CREATURE: nObjectType = 5; break; + case OBJECT_TYPE_DOOR: nObjectType = 10; break; + case OBJECT_TYPE_ENCOUNTER: nObjectType = 13; break; + case OBJECT_TYPE_ITEM: nObjectType = 6; break; + case OBJECT_TYPE_PLACEABLE: nObjectType = 9; break; + case OBJECT_TYPE_STORE: nObjectType = 14; break; + case OBJECT_TYPE_TRIGGER: nObjectType = 7; break; + case OBJECT_TYPE_WAYPOINT: nObjectType = 12; break; + default: nObjectType = 0; break; + } + + return nObjectType; +} +/// @} // End of consts diff --git a/nwnds_module/nwnx_creature.nss b/nwnds_module/nwnx_creature.nss new file mode 100644 index 000000000..0e3486a18 --- /dev/null +++ b/nwnds_module/nwnx_creature.nss @@ -0,0 +1,2150 @@ +/// @addtogroup creature Creature +/// @brief Functions exposing additional creature properties. +/// @{ +/// @file nwnx_creature.nss +#include "nwnx" + +const string NWNX_Creature = "NWNX_Creature"; ///< @private + +/// @name Creature Movement Rates +/// @anchor creature_movement_rates +/// +/// The various types of movement rates. +/// @{ +const int NWNX_CREATURE_MOVEMENT_RATE_PC = 0; +const int NWNX_CREATURE_MOVEMENT_RATE_IMMOBILE = 1; +const int NWNX_CREATURE_MOVEMENT_RATE_VERY_SLOW = 2; +const int NWNX_CREATURE_MOVEMENT_RATE_SLOW = 3; +const int NWNX_CREATURE_MOVEMENT_RATE_NORMAL = 4; +const int NWNX_CREATURE_MOVEMENT_RATE_FAST = 5; +const int NWNX_CREATURE_MOVEMENT_RATE_VERY_FAST = 6; +const int NWNX_CREATURE_MOVEMENT_RATE_DEFAULT = 7; +const int NWNX_CREATURE_MOVEMENT_RATE_DM_FAST = 8; +/// @} + +/// @name Creature Movement Types +/// @anchor creature_movement_types +/// +/// The various types of movement types. +/// @{ +const int NWNX_CREATURE_MOVEMENT_TYPE_STATIONARY = 0; +const int NWNX_CREATURE_MOVEMENT_TYPE_WALK = 1; +const int NWNX_CREATURE_MOVEMENT_TYPE_RUN = 2; +const int NWNX_CREATURE_MOVEMENT_TYPE_SIDESTEP = 3; +const int NWNX_CREATURE_MOVEMENT_TYPE_WALK_BACKWARDS = 4; +/// @} + +/// @name Cleric Domains +/// @anchor cleric_domains +/// +/// The clerical domains. +/// @{ +const int NWNX_CREATURE_CLERIC_DOMAIN_AIR = 0; +const int NWNX_CREATURE_CLERIC_DOMAIN_ANIMAL = 1; +const int NWNX_CREATURE_CLERIC_DOMAIN_DEATH = 3; +const int NWNX_CREATURE_CLERIC_DOMAIN_DESTRUCTION = 4; +const int NWNX_CREATURE_CLERIC_DOMAIN_EARTH = 5; +const int NWNX_CREATURE_CLERIC_DOMAIN_EVIL = 6; +const int NWNX_CREATURE_CLERIC_DOMAIN_FIRE = 7; +const int NWNX_CREATURE_CLERIC_DOMAIN_GOOD = 8; +const int NWNX_CREATURE_CLERIC_DOMAIN_HEALING = 9; +const int NWNX_CREATURE_CLERIC_DOMAIN_KNOWLEDGE = 10; +const int NWNX_CREATURE_CLERIC_DOMAIN_MAGIC = 13; +const int NWNX_CREATURE_CLERIC_DOMAIN_PLANT = 14; +const int NWNX_CREATURE_CLERIC_DOMAIN_PROTECTION = 15; +const int NWNX_CREATURE_CLERIC_DOMAIN_STRENGTH = 16; +const int NWNX_CREATURE_CLERIC_DOMAIN_SUN = 17; +const int NWNX_CREATURE_CLERIC_DOMAIN_TRAVEL = 18; +const int NWNX_CREATURE_CLERIC_DOMAIN_TRICKERY = 19; +const int NWNX_CREATURE_CLERIC_DOMAIN_WAR = 20; +const int NWNX_CREATURE_CLERIC_DOMAIN_WATER = 21; +/// @} + +/// @name Bonus Types +/// @anchor bonus_types +/// +/// Used with NWNX_Creature_GetTotalEffectBonus() these are the types of temporary bonuses from effects. +/// @{ +const int NWNX_CREATURE_BONUS_TYPE_ATTACK = 1; +const int NWNX_CREATURE_BONUS_TYPE_DAMAGE = 2; +const int NWNX_CREATURE_BONUS_TYPE_SAVING_THROW = 3; +const int NWNX_CREATURE_BONUS_TYPE_ABILITY = 4; +const int NWNX_CREATURE_BONUS_TYPE_SKILL = 5; +const int NWNX_CREATURE_BONUS_TYPE_TOUCH_ATTACK = 6; +/// @} + +/// @struct NWNX_Creature_SpecialAbility +/// @brief A creature special ability. +struct NWNX_Creature_SpecialAbility +{ + int id; ///< The spell id + int ready; ///< Whether it can be used + int level; ///< The level of the ability +}; + +/// @struct NWNX_Creature_MemorisedSpell +/// @brief A memorised spell structure. +struct NWNX_Creature_MemorisedSpell +{ + int id; ///< Spell ID + int ready; ///< Whether the spell can be cast + int meta; ///< Metamagic type, if any + int domain; ///< Clerical domain, if any +}; + +/// @brief Gives the creature a feat. +/// @param creature The creature object. +/// @param feat The feat id. +/// @remark Consider also using NWNX_Creature_AddFeatByLevel() to properly allocate the feat to a level +void NWNX_Creature_AddFeat(object creature, int feat); + +/// @brief Gives the creature a feat assigned at a level +/// @param creature The creature object. +/// @param feat The feat id. +/// @param level The level they gained the feat. +/// @remark Adds the feat to the stat list at the provided level. +void NWNX_Creature_AddFeatByLevel(object creature, int feat, int level); + +/// @brief Removes a feat from a creature. +/// @param creature The creature object. +/// @param feat The feat id. +void NWNX_Creature_RemoveFeat(object creature, int feat); + +/// @brief Determines if the creature knows a feat. +/// @note This differs from native @nwn{GetHasFeat} which returns FALSE if the feat has no more uses per day. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return TRUE if the creature has the feat, regardless if they have any usages left or not. +int NWNX_Creature_GetKnowsFeat(object creature, int feat); + +/// @brief Returns the count of feats learned at the provided level. +/// @param creature The creature object. +/// @param level The level. +/// @return The count of feats. +int NWNX_Creature_GetFeatCountByLevel(object creature, int level); + +/// @brief Returns the feat learned at the level and index. +/// @param creature The creature object. +/// @param level The level. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetFeatCountByLevel(). +/// @return The feat id at the index. +int NWNX_Creature_GetFeatByLevel(object creature, int level, int index); + +/// @brief Returns the creature level where the specified feat was learned. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return The character level that the specified feat was granted, otherwise 0 if the creature does not have this feat. +int NWNX_Creature_GetFeatGrantLevel(object creature, int feat); + +/// @brief Get the total number of feats known by creature. +/// @param creature The creature object. +/// @return The total feat count for the creature. +int NWNX_Creature_GetFeatCount(object creature); + +/// @brief Returns the creature's feat at a given index +/// @param creature The creature object. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetFeatCount(); +/// @return The feat id at the index. +int NWNX_Creature_GetFeatByIndex(object creature, int index); + +/// @brief Gets if creature meets feat requirements. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return TRUE if creature meets all requirements to take given feat +int NWNX_Creature_GetMeetsFeatRequirements(object creature, int feat); + +/// @brief Gets the count of special abilities of the creature. +/// @param creature The creature object. +/// @return The total special ability count. +int NWNX_Creature_GetSpecialAbilityCount(object creature); + +/// @brief Returns the creature's special ability at a given index. +/// @param creature The creature object. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetSpecialAbilityCount(). +/// @return An NWNX_Creature_SpecialAbility struct. +struct NWNX_Creature_SpecialAbility NWNX_Creature_GetSpecialAbility(object creature, int index); + +/// @brief Adds a special ability to a creature. +/// @param creature The creature object. +/// @param ability An NWNX_Creature_SpecialAbility struct. +void NWNX_Creature_AddSpecialAbility(object creature, struct NWNX_Creature_SpecialAbility ability); + +/// @brief Removes a special ability from a creature. +/// @param creature The creature object. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetSpecialAbilityCount(). +void NWNX_Creature_RemoveSpecialAbility(object creature, int index); + +/// @brief Sets a special ability at the index for the creature. +/// @param creature The creature object. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetSpecialAbilityCount(). +/// @param ability An NWNX_Creature_SpecialAbility struct. +void NWNX_Creature_SetSpecialAbility(object creature, int index, struct NWNX_Creature_SpecialAbility ability); + +/// @brief Get the class taken by the creature at the provided level. +/// @param creature The creature object. +/// @param level The level. +/// @return The class id. +int NWNX_Creature_GetClassByLevel(object creature, int level); + +/// @brief Sets the base AC for the creature. +/// @param creature The creature object. +/// @param ac The base AC to set for the creature. +void NWNX_Creature_SetBaseAC(object creature, int ac); + +/// @brief Get the base AC for the creature. +/// @param creature The creature object. +/// @return The base AC. +int NWNX_Creature_GetBaseAC(object creature); + +/// @brief Sets the ability score of the creature to the provided value. +/// @note Does not apply racial bonuses/penalties. +/// @param creature The creature object. +/// @param ability The ability constant. +/// @param value The value to set. +void NWNX_Creature_SetRawAbilityScore(object creature, int ability, int value); + +/// @brief Gets the ability score of the creature. +/// @note Does not apply racial bonuses/penalties. +/// @param creature The creature object. +/// @param ability The ability constant. +/// @return The ability score. +int NWNX_Creature_GetRawAbilityScore(object creature, int ability); + +/// @brief Adjusts the ability score of a creature. +/// @note Does not apply racial bonuses/penalties. +/// @param creature The creature object. +/// @param ability The ability constant. +/// @param modifier The modifier value. +void NWNX_Creature_ModifyRawAbilityScore(object creature, int ability, int modifier); + +/// @brief Gets the raw ability score a polymorphed creature had prior to polymorphing. +/// @note For Strength, Dexterity and Constitution only. +/// @param creature The creature object. +/// @param ability The ability constant. +/// @return The raw ability score. +int NWNX_Creature_GetPrePolymorphAbilityScore(object creature, int ability); + +/// @brief Gets the count of memorised spells for a creature's class at a level. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @return The memorised spell count. +int NWNX_Creature_GetMemorisedSpellCountByLevel(object creature, int class, int level); + +/// @brief Gets the memorised spell at a class level's index. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetMemorisedSpellCountByLevel(). +/// @return An NWNX_Creature_MemorisedSpell() struct. +struct NWNX_Creature_MemorisedSpell NWNX_Creature_GetMemorisedSpell(object creature, int class, int level, int index); + +/// @brief Sets the memorised spell at a class level's index. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetMemorisedSpellCountByLevel(). +/// @param spell An NWNX_Creature_MemorisedSpell() struct. +void NWNX_Creature_SetMemorisedSpell(object creature, int class, int level, int index, struct NWNX_Creature_MemorisedSpell spell); + +/// @brief Gets the remaining spell slots (innate casting) at a class level's index. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @return The remaining spell slot count. +int NWNX_Creature_GetRemainingSpellSlots(object creature, int class, int level); + +/// @brief Sets the remaining spell slots (innate casting) at a class level. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param slots The remaining spell slots to set. +void NWNX_Creature_SetRemainingSpellSlots(object creature, int class, int level, int slots); + +/// @brief Gets the maximum spell slots (innate casting) at a class level. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @return The maximum spell slot count. +int NWNX_Creature_GetMaxSpellSlots(object creature, int class, int level); + +/// @brief Gets the known spell count (innate casting) at a class level. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @return The known spell count. +int NWNX_Creature_GetKnownSpellCount(object creature, int class, int level); + +/// @brief Gets the known spell at a class level's index. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetKnownSpellCount(). +/// @return The spell id. +int NWNX_Creature_GetKnownSpell(object creature, int class, int level, int index); + +/// @brief Add a spell to a creature's spellbook for class. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param spellId The spell to remove. +void NWNX_Creature_AddKnownSpell(object creature, int class, int level, int spellId); + +/// @brief Remove a spell from creature's spellbook for class. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param spellId The spell to remove. +void NWNX_Creature_RemoveKnownSpell(object creature, int class, int level, int spellId); + +/// @brief Clear a specific spell from the creature's spellbook for class +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param spellId The spell to clear. +void NWNX_Creature_ClearMemorisedKnownSpells(object creature, int class, int spellId); + +/// @brief Clear the memorised spell of the creature for the class, level and index. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param level The spell level. +/// @param index The index. Index bounds: 0 <= index < NWNX_Creature_GetMemorisedSpellCountByLevel(). +void NWNX_Creature_ClearMemorisedSpell(object creature, int class, int level, int index); + +/// @brief Gets the maximum hit points for creature for level. +/// @param creature The creature object. +/// @param level The level. +/// @return The maximum hit points a creature can have for the class at the provided level. +int NWNX_Creature_GetMaxHitPointsByLevel(object creature, int level); + +/// @brief Sets the maximum hit points for creature. +/// @param creature The creature object. +/// @param level The level. +/// @param value The amount to set the max hit points. +void NWNX_Creature_SetMaxHitPointsByLevel(object creature, int level, int value); + +/// @brief Set creature's movement rate. +/// @param creature The creature object. +/// @param rate The movement rate. +void NWNX_Creature_SetMovementRate(object creature, int rate); + +/// @brief Returns the creature's current movement rate factor. +/// @remark Base movement rate factor is 1.0. +/// @param creature The creature object. +/// @return The current movement rate factor. +float NWNX_Creature_GetMovementRateFactor(object creature); + +/// @brief Sets the creature's current movement rate factor. +/// @note Base movement rate factor is 1.0. +/// @param creature The creature object. +/// @param rate The rate to set. +void NWNX_Creature_SetMovementRateFactor(object creature, float rate); + +/// @brief Sets the creature's maximum movement rate cap. +/// @note Default movement rate cap is 1.5. +/// @param creature The creature object. +/// @param cap The cap to set. +void NWNX_Creature_SetMovementRateFactorCap(object creature, float cap); + +/// @brief Returns the creature's current movement type +/// @param creature The creature object. +/// @return An NWNX_CREATURE_MOVEMENT_TYPE_* constant. +int NWNX_Creature_GetMovementType(object creature); + +/// @brief Sets the maximum movement rate a creature can have while walking (not running) +/// @remark This allows a creature with movement speed enhancements to walk at a normal rate. +/// @param creature The creature object. +/// @param fWalkRate The walk rate to apply. Setting the value to -1.0 will remove the cap. +/// Default value is 2000.0, which is the base human walk speed. +void NWNX_Creature_SetWalkRateCap(object creature, float fWalkRate = 2000.0f); + +/// @brief Set creature's raw good/evil alignment value. +/// @param creature The creature object. +/// @param value The value to set. +void NWNX_Creature_SetAlignmentGoodEvil(object creature, int value); + +/// @brief Set creature's raw law/chaos alignment value. +/// @param creature The creature object. +/// @param value The value to set. +void NWNX_Creature_SetAlignmentLawChaos(object creature, int value); + +/// @brief Get the soundset index for creature. +/// @param creature The creature object. +/// @return The soundset used by the creature. +int NWNX_Creature_GetSoundset(object creature); + +/// @brief Set the soundset index for creature. +/// @param creature The creature object. +/// @param soundset The soundset index. +void NWNX_Creature_SetSoundset(object creature, int soundset); + +/// @brief Set the base ranks in a skill for creature +/// @param creature The creature object. +/// @param skill The skill id. +/// @param rank The value to set as the skill rank. +void NWNX_Creature_SetSkillRank(object creature, int skill, int rank); + +/// @brief Set the class ID in a particular position for a creature. +/// @param creature The creature object. +/// @param position Should be 0, 1, or 2 depending on how many classes the creature +/// has and which is to be modified. +/// @param classID A valid ID number in classes.2da and between 0 and 255. +void NWNX_Creature_SetClassByPosition(object creature, int position, int classID); + +/// @brief Set the level at the given position for a creature. +/// @note A creature should already have a class in that position. +/// @param creature The creature object. +/// @param position Should be 0, 1, or 2 depending on how many classes the creature +/// has and which is to be modified. +/// @param level The level to set. +void NWNX_Creature_SetLevelByPosition(object creature, int position, int level); + +/// @brief Set creature's base attack bonus (BAB). +/// @note Modifying the BAB will also affect the creature's attacks per round and its +/// eligibility for feats, prestige classes, etc. +/// @param creature The creature object. +/// @param bab The BAB value. Should be between 0 and 254. Setting BAB to 0 will cause the +/// creature to revert to its original BAB based on its classes and levels. A creature can +/// never have an actual BAB of zero. +/// @remark The base game has a function @nwn{SetBaseAttackBonus}, which actually sets +/// the bonus attacks per round for a creature, not the BAB. +void NWNX_Creature_SetBaseAttackBonus(object creature, int bab); + +/// @brief Gets the creatures current attacks per round (using equipped weapon). +/// @param creature The creature object. +/// @param bBaseAPR If TRUE, will return the base attacks per round, based on BAB and +/// equipped weapons, regardless of overrides set by calls to @nwn{SetBaseAttackBonus} builtin function. +/// @return The attacks per round. +int NWNX_Creature_GetAttacksPerRound(object creature, int bBaseAPR = FALSE); + +/// @brief Sets the creature gender. +/// @param creature The creature object. +/// @param gender The GENDER_ constant. +void NWNX_Creature_SetGender(object creature, int gender); + +/// @brief Restore all creature feat uses. +/// @param creature The creature object. +void NWNX_Creature_RestoreFeats(object creature); + +/// @brief Restore all creature special ability uses. +/// @param creature The creature object. +void NWNX_Creature_RestoreSpecialAbilities(object creature); + +/// @brief Restore all creature spells per day for given level. +/// @param creature The creature object. +/// @param level The level to restore. If -1, all spells are restored. +void NWNX_Creature_RestoreSpells(object creature, int level = -1); + +/// @brief Restore uses for all items carried by the creature. +/// @param creature The creature object. +void NWNX_Creature_RestoreItems(object creature); + +/// @brief Sets the creature size. +/// @param creature The creature object. +/// @param size Use CREATURE_SIZE_* constants. +void NWNX_Creature_SetSize(object creature, int size); + +/// @brief Gets the creature's remaining unspent skill points. +/// @param creature The creature object. +/// @return The remaining unspent skill points. +int NWNX_Creature_GetSkillPointsRemaining(object creature); + +/// @brief Sets the creature's remaining unspent skill points. +/// @param creature The creature object. +/// @param skillpoints The value to set. +void NWNX_Creature_SetSkillPointsRemaining(object creature, int skillpoints); + +/// @brief Sets the creature's racial type +/// @param creature The creature object. +/// @param racialtype The racial type to set. +void NWNX_Creature_SetRacialType(object creature, int racialtype); + +/// @brief Sets the creature's gold without sending a feedback message +/// @param creature The creature object. +/// @param gold The amount of gold to set for their creature. +void NWNX_Creature_SetGold(object creature, int gold); + +/// @brief Sets corpse decay time in milliseconds +/// @param creature The creature object. +/// @param nDecayTime The corpse decay time. +void NWNX_Creature_SetCorpseDecayTime(object creature, int nDecayTime); + +/// @brief Gets the creature's base save. +/// @param creature The creature object. +/// @param which One of SAVING_THROW_FORT, SAVING_THROW_REFLEX or SAVING_THROW_WILL +/// @return The base save value. +/// @note This will include any modifiers set in the toolset. +int NWNX_Creature_GetBaseSavingThrow(object creature, int which); + +/// @brief Sets the creature's base save. +/// @param creature The creature object. +/// @param which One of SAVING_THROW_FORT, SAVING_THROW_REFLEX or SAVING_THROW_WILL +/// @param value The base save value. +void NWNX_Creature_SetBaseSavingThrow(object creature, int which, int value); + +/// @brief Add levels of class to the creature, bypassing all validation +/// @param creature The creature object. +/// @param class The class id. +/// @param count The amount of levels of class to add. +/// @note This will not work on player characters. +void NWNX_Creature_LevelUp(object creature, int class, int count=1); + +/// @brief Remove last levels from a creature. +/// @param creature The creature object. +/// @param count The amount of levels to decrement. +/// @note This will not work on player characters. +void NWNX_Creature_LevelDown(object creature, int count=1); + +/// @brief Sets the creature's challenge rating +/// @param creature The creature object. +/// @param fCR The challenge rating. +void NWNX_Creature_SetChallengeRating(object creature, float fCR); + +/// @brief Returns the creature's highest attack bonus based on its own stats. +/// @note AB vs. Type and +AB on Gauntlets are excluded +/// @param creature The creature object. +/// @param isMelee +/// * TRUE: Get Melee/Unarmed Attack Bonus +/// * FALSE: Get Ranged Attack Bonus +/// * -1: Get Attack Bonus depending on the weapon creature has equipped in its right hand +/// Defaults to Melee Attack Bonus if weapon is invalid or no weapon +/// @param isTouchAttack If the attack was a touch attack. +/// @param isOffhand If the attack was with the offhand. +/// @param includeBaseAttackBonus Should the result include the base attack bonus. +/// @return The highest attack bonus. +int NWNX_Creature_GetAttackBonus(object creature, int isMelee = -1, int isTouchAttack = FALSE, int isOffhand = FALSE, int includeBaseAttackBonus = TRUE); + +/// @brief Get highest level version of feat possessed by creature. +/// @remark For feats that increment in power, for example, barbarian rage. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return The highest level version of the feat. +int NWNX_Creature_GetHighestLevelOfFeat(object creature, int feat); + +/// @brief Get feat remaining uses. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return The amount of remaining uses. +int NWNX_Creature_GetFeatRemainingUses(object creature, int feat); + +/// @brief Get feat total uses. +/// @param creature The creature object. +/// @param feat The feat id. +/// @return The total uses. +int NWNX_Creature_GetFeatTotalUses(object creature, int feat); + +/// @brief Set feat remaining uses. +/// @param creature The creature object. +/// @param feat The feat id. +/// @param uses The amount of remaining uses. +void NWNX_Creature_SetFeatRemainingUses(object creature, int feat, int uses); + +/// @brief Get total effect bonus +/// @remark This exposes the actual bonus value beyond a player's base scores to attack, damage bonus, saves, +/// skills, ability scores, and touch attack provided by spells, equipment, potions etc. +/// @param creature The creature object. +/// @param bonusType A @ref bonus_types "Bonus Type" +/// @param target A target object. Used to calculate bonuses versus specific races, alignments, etc. +/// @param isElemental If a damage bonus includes elemental damage. +/// @param isForceMax If the bonus should return the maximum possible. +/// @param savetype A SAVING_THROW_* constant. +/// @param saveSpecificType A SAVING_THROW_TYPE_* constant. +/// @param skill A skill id. +/// @param abilityScore An ABILITY_* constant. +/// @param isOffhand Whether the attack is an offhand attack. +/// @return The bonus value. +int NWNX_Creature_GetTotalEffectBonus(object creature, int bonusType=NWNX_CREATURE_BONUS_TYPE_ATTACK, object target=OBJECT_INVALID, int isElemental=0, int isForceMax=0, int savetype=-1, int saveSpecificType=-1, int skill=-1, int abilityScore=-1, int isOffhand=FALSE); + +/// @brief Set the original first or last name of creature +/// @param creature The creature object. +/// @param name The name to give the creature. +/// @param isLastName TRUE to change their last name, FALSE for first. +/// @note For PCs this will persist to the .bic file if saved. Requires a relog to update. +void NWNX_Creature_SetOriginalName(object creature, string name, int isLastName); + +/// @brief Get the original first or last name of creature +/// @param creature The creature object. +/// @param isLastName TRUE to get last name, FALSE for first name. +/// @return The original first or last name of the creature. +string NWNX_Creature_GetOriginalName(object creature, int isLastName); + +/// @brief Set creature's spell resistance +/// @param creature The creature object. +/// @param sr The spell resistance. +/// @warning This setting will be overwritten by effects and once those effects fade the old setting (typically 0) will be set. +void NWNX_Creature_SetSpellResistance(object creature, int sr); + +/// @brief Set creature's animal companion creature type +/// @param creature The master creature object. +/// @param type The type from ANIMAL_COMPANION_CREATURE_TYPE_*. +void NWNX_Creature_SetAnimalCompanionCreatureType(object creature, int type); + +/// @brief Set creature's familiar creature type +/// @param creature The master creature object. +/// @param type The type from FAMILIAR_CREATURE_TYPE_*. +void NWNX_Creature_SetFamiliarCreatureType(object creature, int type); + +/// @brief Set creature's animal companion's name +/// @param creature The master creature object. +/// @param name The name to give their animal companion. +void NWNX_Creature_SetAnimalCompanionName(object creature, string name); + +/// @brief Set creature's familiar's name +/// @param creature The master creature object. +/// @param name The name to give their familiar. +void NWNX_Creature_SetFamiliarName(object creature, string name); + +/// @brief Get whether the creature can be disarmed. +/// @param creature The creature object. +/// @return TRUE if the creature can be disarmed. +int NWNX_Creature_GetDisarmable(object creature); + +/// @brief Set whether a creature can be disarmed. +/// @param creature The creature object. +/// @param disarmable Set to TRUE if the creature can be disarmed. +void NWNX_Creature_SetDisarmable(object creature, int disarmable); + +/// @brief Gets one of creature's domains. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param index The first or second domain. +/// @deprecated Use GetDomain(). This will be removed in future NWNX releases. +int NWNX_Creature_GetDomain(object creature, int class, int index); + +/// @brief Sets one of creature's domains. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param index The first or second domain. +/// @param domain The domain constant to set. +void NWNX_Creature_SetDomain(object creature, int class, int index, int domain); + +/// @brief Gets the creature's specialist school. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @deprecated Use GetSpecialization(). This will be removed in future NWNX releases. +int NWNX_Creature_GetSpecialization(object creature, int class); + +/// @brief Sets creature's specialist school. +/// @param creature The creature object. +/// @param class The class id from classes.2da. (Not class index 0-2) +/// @param school The school constant. +void NWNX_Creature_SetSpecialization(object creature, int class, int school); + +/// @brief Sets oCreatures faction to be the faction with id nFactionId. +/// @param oCreature The creature. +/// @param nFactionId The faction id we want the creature to join. +void NWNX_Creature_SetFaction(object oCreature, int nFactionId); + +/// @brief Gets the faction id from oCreature +/// @param oCreature the creature we wish to query against +/// @return faction id as an integer, -1 when used against invalid creature or invalid object. +int NWNX_Creature_GetFaction(object oCreature); + +/// @brief Get whether a creature is flat-footed. +/// @param oCreature The creature object. +/// @return TRUE if the creature is flat-footed. +int NWNX_Creature_GetFlatFooted(object oCreature); + +/// @brief Serialize oCreature's quickbar to a base64 string +/// @param oCreature The creature. +/// @return A base64 string representation of oCreature's quickbar. +string NWNX_Creature_SerializeQuickbar(object oCreature); + +/// @brief Deserialize sSerializedQuickbar for oCreature +/// @param oCreature The creature. +/// @param sSerializedQuickbar A base64 string of a quickbar +/// @return TRUE on success +int NWNX_Creature_DeserializeQuickbar(object oCreature, string sSerializedQuickbar); + +/// @brief Sets a caster level modifier for oCreature +/// @param oCreature the target creature +/// @param nClass the class that this modifier will apply to +/// @param nModifier the modifier to apply +/// @param bPersist whether the modifier should be persisted to the .bic file if applicable +void NWNX_Creature_SetCasterLevelModifier(object oCreature, int nClass, int nModifier, int bPersist = FALSE); + +/// @brief Gets the current caster level modifier for oCreature +/// @param oCreature the target creature +/// @param nClass the creature caster class +/// @return the current caster level modifier for the creature +int NWNX_Creature_GetCasterLevelModifier(object oCreature, int nClass); + +/// @brief Sets a caster level override for oCreature +/// @param oCreature the target creature +/// @param nClass the class that this modifier will apply to +/// @param nCasterLevel the caster level override to apply +/// @param bPersist whether the override should be persisted to the .bic file if applicable +void NWNX_Creature_SetCasterLevelOverride(object oCreature, int nClass, int nCasterLevel, int bPersist = FALSE); + +/// @brief Gets the current caster level override for oCreature +/// @param oCreature the target creature +/// @param nClass the creature caster class +/// @return the current caster level override for the creature or -1 if not set +int NWNX_Creature_GetCasterLevelOverride(object oCreature, int nClass); + +/// @brief Move a creature to limbo. +/// @param oCreature The creature object. +void NWNX_Creature_JumpToLimbo(object oCreature); + +/// @brief Sets the critical hit multiplier modifier for the Creature +/// @param oCreature The target creature +/// @param nModifier The modifier to apply +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param bPersist Whether the modifier should persist to .bic file if applicable +/// @param nBaseItem Applies the.modifier only when the attack used this baseitem. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @note Persistence is activated each server reset by the first use of either 'SetCriticalMultiplier*' functions. Recommended to trigger on a dummy target OnModuleLoad to enable persistence. +void NWNX_Creature_SetCriticalMultiplierModifier(object oCreature, int nModifier, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1); + +/// @brief Gets the critical hit multiplier modifier for the Creature +/// @param oCreature The target creature +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param nBaseItem The baseitem modifer to retrieve. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @return the current critical hit multiplier modifier for the creature +int NWNX_Creature_GetCriticalMultiplierModifier(object oCreature, int nHand = 0, int nBaseItem = -1); + +/// @brief Sets the critical hit multiplier override for the Creature. +/// @param oCreature The target creature +/// @param nOverride The override value to apply. -1 to clear override. +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param bPersist Whether the modifier should persist to .bic file if applicable +/// @param nBaseItem Applies the.Override only when the attack used this baseitem. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @note Persistence is activated each server reset by the first use of either 'SetCriticalMultiplier*' functions. Recommended to trigger on a dummy target OnModuleLoad to enable persistence. +void NWNX_Creature_SetCriticalMultiplierOverride(object oCreature, int nOverride, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1); + +/// @brief Gets the critical hit multiplier override for the Creature +/// @param oCreature The target creature +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param nBaseItem The baseitem Override to retrieve. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @return the current critical hit multiplier override for the creature. No override == -1 +int NWNX_Creature_GetCriticalMultiplierOverride(object oCreature, int nHand = 0, int nBaseItem = -1); + +/// @brief Sets the critical hit range modifier for the creature. +/// @param oCreature The target creature +/// @param nModifier The modifier to apply. Positive modifiers reduce critical chance. (I.e. From 18-20, a +1 results in crit range of 19-20) +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param bPersist Whether the modifier should persist to .bic file if applicable +/// @param nBaseItem Applies the.modifier only when the attack used this baseitem. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @note Persistence is activated each server reset by the first use of either 'SetCriticalRange*' functions. Recommended to trigger on a dummy target OnModuleLoad to enable persistence. +void NWNX_Creature_SetCriticalRangeModifier(object oCreature, int nModifier, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1); + +/// @brief Gets the critical hit range modifier for the creature. +/// @param oCreature The target creature +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param nBaseItem The baseitem modifer to retrieve. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @return the current critical hit range modifier for the creature +int NWNX_Creature_GetCriticalRangeModifier(object oCreature, int nHand = 0, int nBaseItem = -1); + +/// @brief Sets the critical hit range Override for the creature. +/// @param oCreature The target creature +/// @param nOverride The new minimum roll to crit. i.e nOverride of 15 results in crit range of 15-20. -1 to clear override. +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param bPersist Whether the modifier should persist to .bic file if applicable +/// @param nBaseItem Applies the.Override only when the attack used this baseitem. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @note Persistence is activated each server reset by the first use of either 'SetCriticalRange*' functions. Recommended to trigger on a dummy target OnModuleLoad to enable persistence. +void NWNX_Creature_SetCriticalRangeOverride(object oCreature, int nOverride, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1); + +/// @brief Sets the critical hit range Override for the creature. +/// @param oCreature The target creature +/// @param nHand 0 for all attacks, 1 for Mainhand, 2 for Offhand +/// @param nBaseItem The baseitem Override to retrieve. BASE_ITEM_GLOVES for Unarmed, '-1' for all +/// @return the current critical hit range override for the creature. No override == -1 +int NWNX_Creature_GetCriticalRangeOverride(object oCreature, int nHand = 0, int nBaseItem = -1); + +/// @brief Add oAssociate as nAssociateType to oCreature +/// @warning Only basic checks are done so care must be taken when using this function +/// @param oCreature The creature to add oAssociate to +/// @param oAssociate The associate, must be a NPC +/// @param nAssociateType The associate type, one of ASSOCIATE_TYPE_*, except _NONE +void NWNX_Creature_AddAssociate(object oCreature, object oAssociate, int nAssociateType); + +/// @brief Set whether an effect icon is flashing or not. +/// @param oCreature The target creature. +/// @param nIconId The icon id, see effecticons.2da. +/// @param bFlashing TRUE for flashing, FALSE for not flashing. +void NWNX_Creature_SetEffectIconFlashing(object oCreature, int nIconId, int bFlashing); + +/// @brief Override the damage level of oCreature. +/// @note Damage levels are the damage state under a creature's name, for example: 'Near Death' +/// @param oCreature The target creature. +/// @param nDamageLevel A damage level, see damagelevels.2da. Allowed values: 0-255 or -1 to remove the override. +void NWNX_Creature_OverrideDamageLevel(object oCreature, int nDamageLevel); + +/// @brief Set the encounter source of oCreature. +/// @param oCreature The target creature. +/// @param oEncounter The source encounter +void NWNX_Creature_SetEncounter(object oCreature, object oEncounter); + +/// @brief Get the encounter source of oCreature. +/// @param oCreature The target creature. +/// @return The encounter, OBJECT_INVALID if not part of an encounter or on error +object NWNX_Creature_GetEncounter(object oCreature); + +/// @brief Get if oCreature is currently bartering. +/// @param oCreature The target creature. +/// @return TRUE if oCreature is bartering, FALSE if not or on error. +int NWNX_Creature_GetIsBartering(object oCreature); + +/// @brief Sets caster level for the last item used. Use in a spellhook or spell event before to set caster level for any spells cast from the item. +/// @param oCreature the creature who used the item. +/// @param nCasterLvl the desired caster level. +void NWNX_Creature_SetLastItemCasterLevel(object oCreature, int nCasterLvl); + +/// @brief Gets the caster level of the last item used. +/// @param oCreature the creature who used the item. +/// @return returns the creatures last used item's level. +int NWNX_Creature_GetLastItemCasterLevel(object oCreature); + +/// @brief Gets the Armor classed of attacked against versus +/// @param oAttacked The one being attacked +/// @param oVersus The one doing the attacking +/// @param nTouch TRUE for touch attacks +/// @return -255 on Error, Flat footed AC if oVersus is invalid or the Attacked AC versus oVersus. +int NWNX_Creature_GetArmorClassVersus(object oAttacked, object oVersus, int nTouch=FALSE); + +/// @brief Gets the current walk animation of oCreature. +/// @param oCreature The target creature. +/// @return -1 on Error, otherwise the walk animation number +int NWNX_Creature_GetWalkAnimation(object oCreature); + +/// @brief Sets the current walk animation of oCreature. +/// @param oCreature The target creature. +/// @param nAnimation The walk animation number. +void NWNX_Creature_SetWalkAnimation(object oCreature, int nAnimation); + +/// @brief Changes the attack modifier depending on the dice roll. Used to skip autofail on 1 and autosucceed on 20 as well. +/// @param oCreature The attacking creature, use OBJECT_INVALID for all. +/// @param nRoll The dice roll to modify. +/// @param nModifier The modifier to the attack, use 0 to turn off autofail for 1/autosucceed for 20 with no attack modifier value. +void NWNX_Creature_SetAttackRollOverride(object oCreature, int nRoll, int nModifier); + +/// @brief Works like the tweak but can be turned on and off for all creatures or single ones. +/// @param oCreature The parrying creature, use OBJECT_INVALID for all. +/// @param bParry TRUE to parry all attacks. +/// @note Use this command on_module_load instead of the NWNX_TWEAKS_PARRY_ALL_ATTACKS tweak if using NWNX_Creature_SetAttackRollOverride() +void NWNX_Creature_SetParryAllAttacks(object oCreature, int bParry); + +/// @brief Gets the NoPermanentDeath flag of oCreature. +/// @param oCreature The target creature. +/// @return TRUE/FALSE or -1 on error. +int NWNX_Creature_GetNoPermanentDeath(object oCreature); + +/// @brief Sets the NoPermanentDeath flag of oCreature. +/// @param oCreature The target creature. +/// @param bNoPermanentDeath TRUE/FALSE. +void NWNX_Creature_SetNoPermanentDeath(object oCreature, int bNoPermanentDeath); + +/// @brief Compute a safe location for oCreature. +/// @param oCreature The target creature. +/// @param vPosition The starting position. +/// @param fRadius The search radius around vPosition. +/// @param bWalkStraightLineRequired Whether the creature must be able to walk in a straight line to the position. +/// @return A safe location as vector, will return vPosition if one wasn't found. Returns {0.0, 0.0, 0.0} on error. +vector NWNX_Creature_ComputeSafeLocation(object oCreature, vector vPosition, float fRadius = 20.0f, int bWalkStraightLineRequired = TRUE); + +/// @brief Update oCreature's perception of oTargetCreature. +/// @param oCreature The creature. +/// @param oTargetCreature The target creature. +void NWNX_Creature_DoPerceptionUpdateOnCreature(object oCreature, object oTargetCreature); + +/// @} + +void NWNX_Creature_AddFeat(object creature, int feat) +{ + string sFunc = "AddFeat"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_AddFeatByLevel(object creature, int feat, int level) +{ + string sFunc = "AddFeatByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RemoveFeat(object creature, int feat) +{ + string sFunc = "RemoveFeat"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetKnowsFeat(object creature, int feat) +{ + string sFunc = "GetKnowsFeat"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatCountByLevel(object creature, int level) +{ + string sFunc = "GetFeatCountByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatByLevel(object creature, int level, int index) +{ + string sFunc = "GetFeatByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatCount(object creature) +{ + string sFunc = "GetFeatCount"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatGrantLevel(object creature, int feat) +{ + string sFunc = "GetFeatGrantLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatByIndex(object creature, int index) +{ + string sFunc = "GetFeatByIndex"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetMeetsFeatRequirements(object creature, int feat) +{ + string sFunc = "GetMeetsFeatRequirements"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +struct NWNX_Creature_SpecialAbility NWNX_Creature_GetSpecialAbility(object creature, int index) +{ + string sFunc = "GetSpecialAbility"; + + struct NWNX_Creature_SpecialAbility ability; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + + ability.level = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + ability.ready = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + ability.id = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + + return ability; +} + +int NWNX_Creature_GetSpecialAbilityCount(object creature) +{ + string sFunc = "GetSpecialAbilityCount"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_AddSpecialAbility(object creature, struct NWNX_Creature_SpecialAbility ability) +{ + string sFunc = "AddSpecialAbility"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.id); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.ready); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RemoveSpecialAbility(object creature, int index) +{ + string sFunc = "RemoveSpecialAbility"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetSpecialAbility(object creature, int index, struct NWNX_Creature_SpecialAbility ability) +{ + string sFunc = "SetSpecialAbility"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.id); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.ready); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability.level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetClassByLevel(object creature, int level) +{ + string sFunc = "GetClassByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetBaseAC(object creature, int ac) +{ + string sFunc = "SetBaseAC"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ac); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetBaseAC(object creature) +{ + string sFunc = "GetBaseAC"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetRawAbilityScore(object creature, int ability, int value) +{ + string sFunc = "SetRawAbilityScore"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, value); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetRawAbilityScore(object creature, int ability) +{ + string sFunc = "GetRawAbilityScore"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_ModifyRawAbilityScore(object creature, int ability, int modifier) +{ + string sFunc = "ModifyRawAbilityScore"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, modifier); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetPrePolymorphAbilityScore(object creature, int ability) +{ + string sFunc = "GetPrePolymorphAbilityScore"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, ability); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +struct NWNX_Creature_MemorisedSpell NWNX_Creature_GetMemorisedSpell(object creature, int class, int level, int index) +{ + string sFunc = "GetMemorisedSpell"; + struct NWNX_Creature_MemorisedSpell spell; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + + spell.domain = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + spell.meta = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + spell.ready = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + spell.id = NWNX_GetReturnValueInt(NWNX_Creature, sFunc); + return spell; +} + +int NWNX_Creature_GetMemorisedSpellCountByLevel(object creature, int class, int level) +{ + string sFunc = "GetMemorisedSpellCountByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetMemorisedSpell(object creature, int class, int level, int index, struct NWNX_Creature_MemorisedSpell spell) +{ + string sFunc = "SetMemorisedSpell"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spell.id); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spell.ready); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spell.meta); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spell.domain); + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetRemainingSpellSlots(object creature, int class, int level) +{ + string sFunc = "GetRemainingSpellSlots"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetRemainingSpellSlots(object creature, int class, int level, int slots) +{ + string sFunc = "SetRemainingSpellSlots"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, slots); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetKnownSpell(object creature, int class, int level, int index) +{ + string sFunc = "GetKnownSpell"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetKnownSpellCount(object creature, int class, int level) +{ + string sFunc = "GetKnownSpellCount"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RemoveKnownSpell(object creature, int class, int level, int spellId) +{ + string sFunc = "RemoveKnownSpell"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spellId); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_AddKnownSpell(object creature, int class, int level, int spellId) +{ + string sFunc = "AddKnownSpell"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spellId); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_ClearMemorisedKnownSpells(object creature, int class, int spellId) +{ + string sFunc = "ClearMemorisedKnownSpells"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, spellId); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_ClearMemorisedSpell(object creature, int class, int level, int index) +{ + string sFunc = "ClearMemorisedSpell"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetMaxSpellSlots(object creature, int class, int level) +{ + string sFunc = "GetMaxSpellSlots"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + + +int NWNX_Creature_GetMaxHitPointsByLevel(object creature, int level) +{ + string sFunc = "GetMaxHitPointsByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetMaxHitPointsByLevel(object creature, int level, int value) +{ + string sFunc = "SetMaxHitPointsByLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, value); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetMovementRate(object creature, int rate) +{ + string sFunc = "SetMovementRate"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, rate); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +float NWNX_Creature_GetMovementRateFactor(object creature) +{ + string sFunc = "GetMovementRateFactor"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueFloat(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetMovementRateFactor(object creature, float factor) +{ + string sFunc = "SetMovementRateFactor"; + + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, factor); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetMovementRateFactorCap(object creature, float cap) +{ + string sFunc = "SetMovementRateFactorCap"; + + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, cap); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetAlignmentGoodEvil(object creature, int value) +{ + string sFunc = "SetAlignmentGoodEvil"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, value); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetAlignmentLawChaos(object creature, int value) +{ + string sFunc = "SetAlignmentLawChaos"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, value); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetSoundset(object creature) +{ + string sFunc = "GetSoundset"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetSoundset(object creature, int soundset) +{ + string sFunc = "SetSoundset"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, soundset); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetSkillRank(object creature, int skill, int rank) +{ + string sFunc = "SetSkillRank"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, rank); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, skill); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetClassByPosition(object creature, int position, int classID) +{ + string sFunc = "SetClassByPosition"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, classID); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, position); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetLevelByPosition(object creature, int position, int level) +{ + string sFunc = "SetLevelByPosition"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, position); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetBaseAttackBonus(object creature, int bab) +{ + string sFunc = "SetBaseAttackBonus"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bab); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetAttacksPerRound(object creature, int bBaseAPR = FALSE) +{ + string sFunc = "GetAttacksPerRound"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bBaseAPR); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetGender(object creature, int gender) +{ + string sFunc = "SetGender"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, gender); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RestoreFeats(object creature) +{ + string sFunc = "RestoreFeats"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RestoreSpecialAbilities(object creature) +{ + string sFunc = "RestoreSpecialAbilities"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RestoreSpells(object creature, int level = -1) +{ + string sFunc = "RestoreSpells"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, level); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_RestoreItems(object creature) +{ + string sFunc = "RestoreItems"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetSize(object creature, int size) +{ + string sFunc = "SetSize"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, size); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetSkillPointsRemaining(object creature) +{ + string sFunc = "GetSkillPointsRemaining"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + + +void NWNX_Creature_SetSkillPointsRemaining(object creature, int skillpoints) +{ + string sFunc = "SetSkillPointsRemaining"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, skillpoints); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetRacialType(object creature, int racialtype) +{ + string sFunc = "SetRacialType"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, racialtype); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetMovementType(object creature) +{ + string sFunc = "GetMovementType"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetWalkRateCap(object creature, float fWalkRate = 2000.0f) +{ + string sFunc = "SetWalkRateCap"; + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, fWalkRate); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetGold(object creature, int gold) +{ + string sFunc = "SetGold"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, gold); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCorpseDecayTime(object creature, int nDecayTime) +{ + string sFunc = "SetCorpseDecayTime"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nDecayTime); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + + +int NWNX_Creature_GetBaseSavingThrow(object creature, int which) +{ + string sFunc = "GetBaseSavingThrow"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, which); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetBaseSavingThrow(object creature, int which, int value) +{ + string sFunc = "SetBaseSavingThrow"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, value); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, which); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_LevelUp(object creature, int class, int count=1) +{ + string sFunc = "LevelUp"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, count); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_LevelDown(object creature, int count=1) +{ + string sFunc = "LevelDown"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, count); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetChallengeRating(object creature, float fCR) +{ + string sFunc = "SetChallengeRating"; + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, fCR); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetAttackBonus(object creature, int isMelee = -1, int isTouchAttack = FALSE, int isOffhand = FALSE, int includeBaseAttackBonus = TRUE) +{ + string sFunc = "GetAttackBonus"; + + if (isMelee == -1) + { + object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, creature); + + if (GetIsObjectValid(oWeapon)) + { + isMelee = !GetWeaponRanged(oWeapon); + } + else + {// Default to melee for unarmed + isMelee = TRUE; + } + } + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, includeBaseAttackBonus); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isOffhand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isTouchAttack); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isMelee); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetHighestLevelOfFeat(object creature, int feat) +{ + string sFunc = "GetHighestLevelOfFeat"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatRemainingUses(object creature, int feat) +{ + string sFunc = "GetFeatRemainingUses"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFeatTotalUses(object creature, int feat) +{ + string sFunc = "GetFeatTotalUses"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetFeatRemainingUses(object creature, int feat, int uses) +{ + string sFunc = "SetFeatRemainingUses"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, uses); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, feat); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetTotalEffectBonus(object creature, int bonusType=NWNX_CREATURE_BONUS_TYPE_ATTACK, object target=OBJECT_INVALID, int isElemental=0, int isForceMax=0, int savetype=-1, int saveSpecificType=-1, int skill=-1, int abilityScore=-1, int isOffhand=FALSE) +{ + string sFunc = "GetTotalEffectBonus"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isOffhand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, abilityScore); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, skill); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, saveSpecificType); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, savetype); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isForceMax); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isElemental); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, target); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bonusType); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetOriginalName(object creature, string name, int isLastName) +{ + string sFunc = "SetOriginalName"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isLastName); + NWNX_PushArgumentString(NWNX_Creature, sFunc, name); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +string NWNX_Creature_GetOriginalName(object creature, int isLastName) +{ + string sFunc = "GetOriginalName"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, isLastName); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueString(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetSpellResistance(object creature, int sr) +{ + string sFunc = "SetSpellResistance"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, sr); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetAnimalCompanionCreatureType(object creature, int type) +{ + string sFunc = "SetAnimalCompanionCreatureType"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, type); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetFamiliarCreatureType(object creature, int type) +{ + string sFunc = "SetFamiliarCreatureType"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, type); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetAnimalCompanionName(object creature, string name) +{ + string sFunc = "SetAnimalCompanionName"; + + NWNX_PushArgumentString(NWNX_Creature, sFunc, name); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetFamiliarName(object creature, string name) +{ + string sFunc = "SetFamiliarName"; + + NWNX_PushArgumentString(NWNX_Creature, sFunc, name); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetDisarmable(object creature) +{ + string sFunc = "GetDisarmable"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetDisarmable(object creature, int disarmable) +{ + string sFunc = "SetDisarmable"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, disarmable); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetDomain(object creature, int class, int index) +{ + WriteTimestampedLogEntry("NWNX_Creature: GetDomain() is deprecated. Please use the basegame's GetDomain() instead"); + + return GetDomain(creature, index, class); +} + +void NWNX_Creature_SetDomain(object creature, int class, int index, int domain) +{ + string sFunc = "SetDomain"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, domain); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, index); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetSpecialization(object creature, int class) +{ + WriteTimestampedLogEntry("NWNX_Creature: GetSpecialization() is deprecated. Please use the basegame's GetSpecialization() instead"); + + return GetSpecialization(creature, class); +} + +void NWNX_Creature_SetSpecialization(object creature, int class, int school) +{ + string sFunc = "SetSpecialization"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, school); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, class); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, creature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetFaction(object oCreature, int nFactionId) +{ + string sFunc = "SetFaction"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nFactionId); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFaction(object oCreature) +{ + string sFunc = "GetFaction"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetFlatFooted(object oCreature) +{ + string sFunc = "GetFlatFooted"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +string NWNX_Creature_SerializeQuickbar(object oCreature) +{ + string sFunc = "SerializeQuickbar"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueString(NWNX_Creature, sFunc); +} + +int NWNX_Creature_DeserializeQuickbar(object oCreature, string sSerializedQuickbar) +{ + string sFunc = "DeserializeQuickbar"; + + NWNX_PushArgumentString(NWNX_Creature, sFunc, sSerializedQuickbar); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCasterLevelModifier(object oCreature, int nClass, int nModifier, int bPersist = FALSE) +{ + string sFunc = "SetCasterLevelModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nModifier); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nClass); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCasterLevelModifier(object oCreature, int nClass) +{ + string sFunc = "GetCasterLevelModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nClass); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCasterLevelOverride(object oCreature, int nClass, int nCasterLevel, int bPersist = FALSE) +{ + string sFunc = "SetCasterLevelOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nCasterLevel); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nClass); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCasterLevelOverride(object oCreature, int nClass) +{ + string sFunc = "GetCasterLevelOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nClass); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_JumpToLimbo(object oCreature) +{ + string sFunc = "JumpToLimbo"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCriticalMultiplierModifier(object oCreature, int nModifier, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1) +{ + string sFunc = "SetCriticalMultiplierModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nModifier); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCriticalMultiplierModifier(object oCreature, int nHand = 0, int nBaseItem = -1) +{ + string sFunc = "GetCriticalMultiplierModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCriticalMultiplierOverride(object oCreature, int nOverride, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1) +{ + string sFunc = "SetCriticalMultiplierOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nOverride); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCriticalMultiplierOverride(object oCreature, int nHand = 0, int nBaseItem = -1) +{ + string sFunc = "GetCriticalMultiplierOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCriticalRangeModifier(object oCreature, int nModifier, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1) +{ + string sFunc = "SetCriticalRangeModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nModifier); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCriticalRangeModifier(object oCreature, int nHand = 0, int nBaseItem = -1) +{ + string sFunc = "GetCriticalRangeModifier"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetCriticalRangeOverride(object oCreature, int nOverride, int nHand = 0, int bPersist = FALSE, int nBaseItem = -1) +{ + string sFunc = "SetCriticalRangeOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nOverride); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetCriticalRangeOverride(object oCreature, int nHand = 0, int nBaseItem = -1) +{ + string sFunc = "GetCriticalRangeOverride"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nBaseItem); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nHand); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_AddAssociate(object oCreature, object oAssociate, int nAssociateType) +{ + string sFunc = "AddAssociate"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nAssociateType); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oAssociate); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetEffectIconFlashing(object oCreature, int nIconId, int bFlashing) +{ + string sFunc = "SetEffectIconFlashing"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bFlashing); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nIconId); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_OverrideDamageLevel(object oCreature, int nDamageLevel) +{ + string sFunc = "OverrideDamageLevel"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nDamageLevel); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetEncounter(object oCreature, object oEncounter) +{ + string sFunc = "SetEncounter"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oEncounter); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +object NWNX_Creature_GetEncounter(object oCreature) +{ + string sFunc = "GetEncounter"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetIsBartering(object oCreature) +{ + string sFunc = "GetIsBartering"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetLastItemCasterLevel(object oCreature, int nCasterLvl) +{ + string sFunc = "SetLastItemCasterLevel"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nCasterLvl); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + + +int NWNX_Creature_GetLastItemCasterLevel(object oCreature) +{ + string sFunc = "GetLastItemCasterLevel"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetArmorClassVersus(object oAttacked, object oVersus, int nTouch=FALSE) +{ + string sFunc = "GetArmorClassVersus"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nTouch); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oVersus); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oAttacked); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetWalkAnimation(object oCreature) +{ + string sFunc = "GetWalkAnimation"; + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetWalkAnimation(object oCreature, int nAnimation) +{ + string sFunc = "SetWalkAnimation"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nAnimation); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetAttackRollOverride(object oCreature, int nRoll, int nModifier) +{ + string sFunc = "SetAttackRollOverride"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nModifier); + NWNX_PushArgumentInt(NWNX_Creature, sFunc, nRoll); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetParryAllAttacks(object oCreature, int bParry) +{ + string sFunc = "SetParryAllAttacks"; + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bParry); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +int NWNX_Creature_GetNoPermanentDeath(object oCreature) +{ + string sFunc = "GetNoPermanentDeath"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Creature, sFunc); +} + +void NWNX_Creature_SetNoPermanentDeath(object oCreature, int bNoPermanentDeath) +{ + string sFunc = "SetNoPermanentDeath"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bNoPermanentDeath); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} + +vector NWNX_Creature_ComputeSafeLocation(object oCreature, vector vPosition, float fRadius = 20.0f, int bWalkStraightLineRequired = TRUE) +{ + string sFunc = "ComputeSafeLocation"; + + NWNX_PushArgumentInt(NWNX_Creature, sFunc, bWalkStraightLineRequired); + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, fRadius); + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, vPosition.x); + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, vPosition.y); + NWNX_PushArgumentFloat(NWNX_Creature, sFunc, vPosition.z); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); + + vector v; + v.z = NWNX_GetReturnValueFloat(NWNX_Creature, sFunc); + v.y = NWNX_GetReturnValueFloat(NWNX_Creature, sFunc); + v.x = NWNX_GetReturnValueFloat(NWNX_Creature, sFunc); + + return v; +} + +void NWNX_Creature_DoPerceptionUpdateOnCreature(object oCreature, object oTargetCreature) +{ + string sFunc = "DoPerceptionUpdateOnCreature"; + + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oTargetCreature); + NWNX_PushArgumentObject(NWNX_Creature, sFunc, oCreature); + NWNX_CallFunction(NWNX_Creature, sFunc); +} diff --git a/nwnds_module/nwnx_damage.nss b/nwnds_module/nwnx_damage.nss new file mode 100644 index 000000000..3e206ea2e --- /dev/null +++ b/nwnds_module/nwnx_damage.nss @@ -0,0 +1,253 @@ +/// @addtogroup damage Damage +/// @brief Run a script before damage and attack events allowing for modification. Includes function to arbitrarily apply damage. +/// @{ +/// @file nwnx_damage.nss +#include "nwnx" + +const string NWNX_Damage = "NWNX_Damage"; ///< @private + +/// @struct NWNX_Damage_DamageEventData +/// @brief Damage Event Data +struct NWNX_Damage_DamageEventData +{ + object oDamager; ///< The object that inflicted the damage. + int iBludgeoning; ///< Bludgeoning damage + int iPierce; ///< Piercing damage + int iSlash; ///< Slashing damage + int iMagical; ///< Magical damage + int iAcid; ///< Acid damage + int iCold; ///< Cold damage + int iDivine; ///< Divine damage + int iElectrical; ///< Electrical damage + int iFire; ///< Fire damage + int iNegative; ///< Negative damage + int iPositive; ///< Positive damage + int iSonic; ///< Sonic damage + int iBase; ///< Base damage +}; + +/// @struct NWNX_Damage_AttackEventData +/// @brief Attack Event Data +struct NWNX_Damage_AttackEventData +{ + object oTarget; ///< The target who took the damage + int iBludgeoning; ///< Bludgeoning damage + int iPierce; ///< Piercing damage + int iSlash; ///< Slashing damage + int iMagical; ///< Magical damage + int iAcid; ///< Acid damage + int iCold; ///< Cold damage + int iDivine; ///< Divine damage + int iElectrical; ///< Electrical damage + int iFire; ///< Fire damage + int iNegative; ///< Negative damage + int iPositive; ///< Positive damage + int iSonic; ///< Sonic damage + int iBase; ///< Base damage + int iAttackNumber; ///< 1-based index of the attack in current combat round + int iAttackResult; ///< 1=hit, 3=critical hit, 4=miss, 8=concealed + int iAttackType; ///< 1=main hand, 2=offhand, 3-5=creature, 6=haste + int iSneakAttack; ///< 0=neither, 1=sneak attack, 2=death attack, 3=both +}; + +/// @struct NWNX_Damage_DamageData +/// @brief Used for DealDamage +struct NWNX_Damage_DamageData +{ + int iBludgeoning; ///< Bludgeoning damage + int iPierce; ///< Piercing damage + int iSlash; ///< Slashing damage + int iMagical; ///< Magical damage + int iAcid; ///< Acid damage + int iCold; ///< Cold damage + int iDivine; ///< Divine damage + int iElectrical; ///< Electrical damage + int iFire; ///< Fire damage + int iNegative; ///< Negative damage + int iPositive; ///< Positive damage + int iSonic; ///< Sonic damage + int iPower; ///< For overcoming DR +}; + +/// @brief Sets the script to run with a damage event. +/// @param sScript The script that will handle the damage event. +/// @param oOwner An object if only executing for a specific object or OBJECT_INVALID for global. +void NWNX_Damage_SetDamageEventScript(string sScript, object oOwner=OBJECT_INVALID); + +/// @brief Get Damage Event Data +/// @return A NWNX_Damage_DamageEventData struct. +/// @note To use only in the Damage Event Script. +struct NWNX_Damage_DamageEventData NWNX_Damage_GetDamageEventData(); + +/// @brief Set Damage Event Data +/// @param data A NWNX_Damage_DamageEventData struct. +/// @note To use only in the Damage Event Script. +void NWNX_Damage_SetDamageEventData(struct NWNX_Damage_DamageEventData data); + +/// @brief Sets the script to run with an attack event. +/// @param sScript The script that will handle the attack event. +/// @param oOwner An object if only executing for a specific object or OBJECT_INVALID for global. +void NWNX_Damage_SetAttackEventScript(string sScript, object oOwner=OBJECT_INVALID); + +/// @brief Get Attack Event Data +/// @return A NWNX_Damage_AttackEventData struct. +/// @note To use only in the Attack Event Script. +struct NWNX_Damage_AttackEventData NWNX_Damage_GetAttackEventData(); + +/// @brief Set Attack Event Data +/// @param data A NWNX_Damage_AttackEventData struct. +/// @note To use only in the Attack Event Script. +void NWNX_Damage_SetAttackEventData(struct NWNX_Damage_AttackEventData data); + +/// @brief Deal damage to a target. +/// @remark Permits multiple damage types and checks enhancement bonus for overcoming DR. +/// @param data A NWNX_Damage_DamageData struct. +/// @param oTarget The target object on whom the damage is dealt. +/// @param oSource The source of the damage. +/// @param iRanged Whether the attack should be treated as ranged by the engine (for example when considering damage inflicted by Acid Sheath and other such effects) +void NWNX_Damage_DealDamage(struct NWNX_Damage_DamageData data, object oTarget, object oSource=OBJECT_SELF, int iRanged = FALSE); + +/// @} + +void NWNX_Damage_SetDamageEventScript(string sScript, object oOwner=OBJECT_INVALID) +{ + string sFunc = "SetEventScript"; + + NWNX_PushArgumentObject(NWNX_Damage, sFunc, oOwner); + NWNX_PushArgumentString(NWNX_Damage, sFunc, sScript); + NWNX_PushArgumentString(NWNX_Damage, sFunc, "DAMAGE"); + + NWNX_CallFunction(NWNX_Damage, sFunc); +} + +struct NWNX_Damage_DamageEventData NWNX_Damage_GetDamageEventData() +{ + string sFunc = "GetDamageEventData"; + struct NWNX_Damage_DamageEventData data; + + NWNX_CallFunction(NWNX_Damage, sFunc); + + data.oDamager = NWNX_GetReturnValueObject(NWNX_Damage, sFunc); + data.iBludgeoning = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iPierce = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iSlash = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iMagical = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iAcid = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iCold = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iDivine = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iElectrical = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iFire = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iNegative = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iPositive = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iSonic = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iBase = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + + return data; +} + +void NWNX_Damage_SetDamageEventData(struct NWNX_Damage_DamageEventData data) +{ + string sFunc = "SetDamageEventData"; + + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iBase); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSonic); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPositive); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iNegative); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iFire); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iElectrical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iDivine); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iCold); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iAcid); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iMagical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSlash); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPierce); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iBludgeoning); + + NWNX_CallFunction(NWNX_Damage, sFunc); +} + +void NWNX_Damage_SetAttackEventScript(string sScript, object oOwner=OBJECT_INVALID) +{ + string sFunc = "SetEventScript"; + + NWNX_PushArgumentObject(NWNX_Damage, sFunc, oOwner); + NWNX_PushArgumentString(NWNX_Damage, sFunc, sScript); + NWNX_PushArgumentString(NWNX_Damage, sFunc, "ATTACK"); + + NWNX_CallFunction(NWNX_Damage, sFunc); +} + +struct NWNX_Damage_AttackEventData NWNX_Damage_GetAttackEventData() +{ + string sFunc = "GetAttackEventData"; + struct NWNX_Damage_AttackEventData data; + + NWNX_CallFunction(NWNX_Damage, sFunc); + + data.oTarget = NWNX_GetReturnValueObject(NWNX_Damage, sFunc); + data.iBludgeoning = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iPierce = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iSlash = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iMagical = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iAcid = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iCold = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iDivine = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iElectrical = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iFire = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iNegative = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iPositive = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iSonic = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iBase = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iAttackNumber = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iAttackResult = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iAttackType = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + data.iSneakAttack = NWNX_GetReturnValueInt(NWNX_Damage, sFunc); + + return data; +} + +void NWNX_Damage_SetAttackEventData(struct NWNX_Damage_AttackEventData data) +{ + string sFunc = "SetAttackEventData"; + + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iAttackResult); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iBase); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSonic); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPositive); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iNegative); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iFire); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iElectrical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iDivine); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iCold); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iAcid); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iMagical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSlash); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPierce); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iBludgeoning); + + NWNX_CallFunction(NWNX_Damage, sFunc); +} + +void NWNX_Damage_DealDamage(struct NWNX_Damage_DamageData data, object oTarget, object oSource, int iRanged = FALSE) +{ + string sFunc = "DealDamage"; + + NWNX_PushArgumentInt(NWNX_Damage, sFunc, iRanged); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPower); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSonic); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPositive); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iNegative); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iFire); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iElectrical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iDivine); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iCold); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iAcid); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iMagical); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iSlash); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iPierce); + NWNX_PushArgumentInt(NWNX_Damage, sFunc, data.iBludgeoning); + NWNX_PushArgumentObject(NWNX_Damage, sFunc, oTarget); + NWNX_PushArgumentObject(NWNX_Damage, sFunc, oSource); + + NWNX_CallFunction(NWNX_Damage, sFunc); +} diff --git a/nwnds_module/nwnx_data.nss b/nwnds_module/nwnx_data.nss new file mode 100644 index 000000000..b900de5b2 --- /dev/null +++ b/nwnds_module/nwnx_data.nss @@ -0,0 +1,351 @@ +/// @addtogroup data Data +/// @brief Provides a number of data structures for NWN code to use (simulated arrays) +/// @{ +/// @file nwnx_data.nss + +#include "inc_array" + +// All these calls just pass through to the Array code in inc_array to provide +// an NWNX_Data compatible API for ease of transition. + +const int NWNX_DATA_INVALID_INDEX = INVALID_INDEX; +const int NWNX_DATA_TYPE_FLOAT = TYPE_FLOAT; +const int NWNX_DATA_TYPE_INTEGER = TYPE_INTEGER; +const int NWNX_DATA_TYPE_OBJECT = TYPE_OBJECT; +const int NWNX_DATA_TYPE_STRING = TYPE_STRING; + +/// @defgroup data_array_at Array At +/// @brief Returns the element at the index. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param index The index. +/// @return The element of associated type. +/// @{ +string NWNX_Data_Array_At_Str(object obj, string tag, int index); +float NWNX_Data_Array_At_Flt(object obj, string tag, int index); +int NWNX_Data_Array_At_Int(object obj, string tag, int index); +object NWNX_Data_Array_At_Obj(object obj, string tag, int index); +/// @} + + +/// Clears the entire array, such that size==0. +void NWNX_Data_Array_Clear(int type, object obj, string tag); + +/// @defgroup data_array_contains Array Contains +/// @brief Checks if array contains the element. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param element The element. +/// @return TRUE if the collection contains the element. +/// @{ +int NWNX_Data_Array_Contains_Flt(object obj, string tag, float element); +int NWNX_Data_Array_Contains_Int(object obj, string tag, int element); +int NWNX_Data_Array_Contains_Obj(object obj, string tag, object element); +int NWNX_Data_Array_Contains_Str(object obj, string tag, string element); +/// @} + +/// Copies the array of name otherTag over the array of name tag. +void NWNX_Data_Array_Copy(int type, object obj, string tag, string otherTag); + +/// Erases the element at index, and shuffles any elements from index size-1 to index + 1 left. +void NWNX_Data_Array_Erase(int type, object obj, string tag, int index); + +/// @defgroup data_array_find Array Find +/// @brief Get the index at which the element is located. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param element The element. +/// @return Returns the index at which the element is located, or ARRAY_INVALID_INDEX. +/// @{ +int NWNX_Data_Array_Find_Flt(object obj, string tag, float element); +int NWNX_Data_Array_Find_Int(object obj, string tag, int element); +int NWNX_Data_Array_Find_Obj(object obj, string tag, object element); +int NWNX_Data_Array_Find_Str(object obj, string tag, string element); +/// @} + +/// @defgroup data_array_insert Array Insert +/// @brief Inserts the element at the index, where size > index >= 0. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param index The index. +/// @param element The element. +/// @{ +void NWNX_Data_Array_Insert_Flt(object obj, string tag, int index, float element); +void NWNX_Data_Array_Insert_Int(object obj, string tag, int index, int element); +void NWNX_Data_Array_Insert_Obj(object obj, string tag, int index, object element); +void NWNX_Data_Array_Insert_Str(object obj, string tag, int index, string element); +/// @} + +/// @defgroup data_array_pushback Array Pushback +/// @brief Pushes an element to the back of the collection. +/// @remark Functionally identical to an insert at index size-1. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param element The element. +/// @{ +void NWNX_Data_Array_PushBack_Flt(object obj, string tag, float element); +void NWNX_Data_Array_PushBack_Int(object obj, string tag, int element); +void NWNX_Data_Array_PushBack_Obj(object obj, string tag, object element); +void NWNX_Data_Array_PushBack_Str(object obj, string tag, string element); +/// @} + +/// Resizes the array. If the array is shrinking, it chops off elements at the ned. +void NWNX_Data_Array_Resize(int type, object obj, string tag, int size); + +/// Reorders the array such each possible permutation of elements has equal probability of appearance. +void NWNX_Data_Array_Shuffle(int type, object obj, string tag); + +/// Returns the size of the array. +int NWNX_Data_Array_Size(int type, object obj, string tag); + +/// Sorts the collection based on descending order. +void NWNX_Data_Array_SortAscending(int type, object obj, string tag); + +/// Sorts the collection based on descending order. +void NWNX_Data_Array_SortDescending(int type, object obj, string tag); + +/// @defgroup data_array_set Array Set +/// @brief Sets the element at the index, where size > index >= 0. +/// @ingroup data +/// @param obj The object. +/// @param tag The tag. +/// @param index The index. +/// @param element The element. +/// @{ +void NWNX_Data_Array_Set_Flt(object obj, string tag, int index, float element); +void NWNX_Data_Array_Set_Int(object obj, string tag, int index, int element); +void NWNX_Data_Array_Set_Obj(object obj, string tag, int index, object element); +void NWNX_Data_Array_Set_Str(object obj, string tag, int index, string element); +/// @} + +/// @} + +//////////////////////////////////////////////////////////////////////////////// +// return the value contained in location "index" +string NWNX_Data_Array_At_Str(object obj, string tag, int index) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_At_Str(tag, index, obj); +} + +float NWNX_Data_Array_At_Flt(object obj, string tag, int index) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_At_Flt(tag, index, obj); +} + +int NWNX_Data_Array_At_Int(object obj, string tag, int index) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_At_Int(tag, index, obj); +} + +object NWNX_Data_Array_At_Obj(object obj, string tag, int index) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_At_Obj(tag, index, obj); +} + +void NWNX_Data_Array_Clear(int type, object obj, string tag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Clear(tag, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Return true/value (1/0) if the array contains the value "element" +int NWNX_Data_Array_Contains_Str(object obj, string tag, string element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Contains_Str(tag, element, obj); +} + +int NWNX_Data_Array_Contains_Flt(object obj, string tag, float element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Contains_Flt(tag, element, obj); +} + +int NWNX_Data_Array_Contains_Int(object obj, string tag, int element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Contains_Int(tag, element, obj); +} + +int NWNX_Data_Array_Contains_Obj(object obj, string tag, object element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Contains_Obj(tag, element, obj); +} + + +//////////////////////////////////////////////////////////////////////////////// +void NWNX_Data_Array_Copy(int type, object obj, string tag, string otherTag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Copy(tag, otherTag, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +void NWNX_Data_Array_Erase(int type, object obj, string tag, int index) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Erase(tag, index, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// return the index in the array containing "element" +// if not found, return NWNX_DATA_INVALID_INDEX +int NWNX_Data_Array_Find_Str(object obj, string tag, string element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Find_Str(tag, element, obj); +} + +int NWNX_Data_Array_Find_Flt(object obj, string tag, float element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Find_Flt(tag, element, obj); +} + +int NWNX_Data_Array_Find_Int(object obj, string tag, int element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Find_Int(tag, element, obj); +} + +int NWNX_Data_Array_Find_Obj(object obj, string tag, object element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Find_Obj(tag, element, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Insert a new element into position 'index'. If index is beyond the number of rows in the array, +// this will quietly fail. This could be changed if you wanted to support sparse +// arrays. +void NWNX_Data_Array_Insert_Str(object obj, string tag, int index, string element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Insert_Str(tag, index, element, obj); +} + +void NWNX_Data_Array_Insert_Flt(object obj, string tag, int index, float element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Insert_Flt(tag, index, element, obj); +} + +void NWNX_Data_Array_Insert_Int(object obj, string tag, int index, int element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Insert_Int(tag, index, element, obj); +} + +void NWNX_Data_Array_Insert_Obj(object obj, string tag, int index, object element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Insert_Obj(tag, index, element, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Insert a new element at the end of the array. +void NWNX_Data_Array_PushBack_Str(object obj, string tag, string element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_PushBack_Str(tag, element, obj); +} + +void NWNX_Data_Array_PushBack_Flt(object obj, string tag, float element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_PushBack_Flt(tag, element, obj); +} + +void NWNX_Data_Array_PushBack_Int(object obj, string tag, int element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_PushBack_Int(tag, element, obj); +} + +void NWNX_Data_Array_PushBack_Obj(object obj, string tag, object element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_PushBack_Obj(tag, element, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Cuts the array off at size 'size'. Elements beyond size are removed. +void NWNX_Data_Array_Resize(int type, object obj, string tag, int size) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Resize(tag, size, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +void NWNX_Data_Array_Shuffle(int type, object obj, string tag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Shuffle(tag, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +int NWNX_Data_Array_Size(int type, object obj, string tag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + return Array_Size(tag, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Sort the array by value according to 'direciton' (ASC or DESC) +// Note that this is a lexical sort, so sorting an array of ints or floats will have +// odd results +void NWNX_Data_Array_Sort(object obj, string tag, string direction) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Sort(tag, direction, TYPE_STRING, obj); +} + +void NWNX_Data_Array_SortAscending(int type, object obj, string tag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_SortAscending(tag, TYPE_STRING, obj); +} + +void NWNX_Data_Array_SortDescending(int type, object obj, string tag) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_SortDescending(tag, TYPE_STRING, obj); +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the value of array index 'index' to a 'element' +// This will quietly eat values if index > array size +void NWNX_Data_Array_Set_Str(object obj, string tag, int index, string element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Set_Str(tag, index, element, obj); +} + +void NWNX_Data_Array_Set_Flt(object obj, string tag, int index, float element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Set_Flt(tag, index, element, obj); +} + +void NWNX_Data_Array_Set_Int(object obj, string tag, int index, int element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Set_Int(tag, index, element, obj); +} + +void NWNX_Data_Array_Set_Obj(object obj, string tag, int index, object element) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Data is deprecated. You should migrate to Array (see inc_array)"); + Array_Set_Obj(tag, index, element, obj); +} diff --git a/nwnds_module/nwnx_dialog.nss b/nwnds_module/nwnx_dialog.nss new file mode 100644 index 000000000..744943b55 --- /dev/null +++ b/nwnds_module/nwnx_dialog.nss @@ -0,0 +1,139 @@ +/// @addtogroup dialog Dialog +/// @brief Functions exposing additional dialog properties +/// @{ +/// @file nwnx_dialog.nss + +#include "nwnx" + +const string NWNX_Dialog = "NWNX_Dialog"; ///< @private + +/// @name Dialog Node Types +/// @anchor dialog_node_types +/// @{ +const int NWNX_DIALOG_NODE_TYPE_INVALID = -1; +const int NWNX_DIALOG_NODE_TYPE_STARTING_NODE = 0; +const int NWNX_DIALOG_NODE_TYPE_ENTRY_NODE = 1; +const int NWNX_DIALOG_NODE_TYPE_REPLY_NODE = 2; +/// @} + +/// @name Dialog Script Types +/// @anchor dialog_script_types +/// @{ +const int NWNX_DIALOG_SCRIPT_TYPE_OTHER = 0; +const int NWNX_DIALOG_SCRIPT_TYPE_STARTING_CONDITIONAL = 1; +const int NWNX_DIALOG_SCRIPT_TYPE_ACTION_TAKEN = 2; +/// @} + +/// @name Dialog Languages +/// @anchor dialog_languages +/// @{ +const int NWNX_DIALOG_LANGUAGE_ENGLISH = 0; +const int NWNX_DIALOG_LANGUAGE_FRENCH = 1; +const int NWNX_DIALOG_LANGUAGE_GERMAN = 2; +const int NWNX_DIALOG_LANGUAGE_ITALIAN = 3; +const int NWNX_DIALOG_LANGUAGE_SPANISH = 4; +const int NWNX_DIALOG_LANGUAGE_POLISH = 5; +const int NWNX_DIALOG_LANGUAGE_KOREAN = 128; +const int NWNX_DIALOG_LANGUAGE_CHINESE_TRADITIONAL = 129; +const int NWNX_DIALOG_LANGUAGE_CHINESE_SIMPLIFIED = 130; +const int NWNX_DIALOG_LANGUAGE_JAPANESE = 131; +/// @} + +/// @brief Get the @ref dialog_node_types "Node Type" of the current text node +/// @return A @ref dialog_node_types "Node Type". If called out of dialog, returns NWNX_DIALOG_NODE_TYPE_INVALID +int NWNX_Dialog_GetCurrentNodeType(); + +/// @brief Get the @ref dialog_script_types "Script Type" of the current text node +/// @return A @ref dialog_script_types "Node Type". If called out of dialog, returns NWNX_DIALOG_SCRIPT_TYPE_OTHER +int NWNX_Dialog_GetCurrentScriptType(); + +/// @brief Get the absolute ID of the current node in the conversation +/// @note NWNX_DIALOG_NODE_TYPE_ENTRY_NODE and NWNX_DIALOG_NODE_TYPE_REPLY_NODE nodes +/// have different namespaces, so they can share the same ID +/// @return The absolute ID in the dialog. If called out of dialog, returns -1 +int NWNX_Dialog_GetCurrentNodeID(); + +/// @brief Get the index of the current node in the list of replies/entries. +/// @note The index is zero based, and counts items not displayed due to a StartingConditional. +/// @return The index of the current node. +int NWNX_Dialog_GetCurrentNodeIndex(); + +/// @brief Get the text of the current node +/// @param language The @ref dialog_languages "language" of the text. +/// @param gender The gender for the text. +string NWNX_Dialog_GetCurrentNodeText(int language=NWNX_DIALOG_LANGUAGE_ENGLISH, int gender=GENDER_MALE); + +/// @brief Set the text of the current node for given language/gender +/// @note This will only work in a starting conditional script (action take comes after the text is displayed) +/// @param text The text for the node. +/// @param language The @ref dialog_languages "language" of the text. +/// @param gender The gender for the text. +void NWNX_Dialog_SetCurrentNodeText(string text, int language=NWNX_DIALOG_LANGUAGE_ENGLISH, int gender=GENDER_MALE); + +/// @brief End a conversation oObject is involved in, it will fire the OnAbort script of the conversation +/// @warning Calling this from a conversation script will crash your server. +/// @param oObject The object in a conversation +void NWNX_Dialog_End(object oObject); + +/// @} + + +int NWNX_Dialog_GetCurrentNodeType() +{ + string sFunc = "GetCurrentNodeType"; + + NWNX_CallFunction(NWNX_Dialog, sFunc); + return NWNX_GetReturnValueInt(NWNX_Dialog, sFunc); +} + +int NWNX_Dialog_GetCurrentScriptType() +{ + string sFunc = "GetCurrentScriptType"; + + NWNX_CallFunction(NWNX_Dialog, sFunc); + return NWNX_GetReturnValueInt(NWNX_Dialog, sFunc); +} + +int NWNX_Dialog_GetCurrentNodeID() +{ + string sFunc = "GetCurrentNodeID"; + + NWNX_CallFunction(NWNX_Dialog, sFunc); + return NWNX_GetReturnValueInt(NWNX_Dialog, sFunc); +} + +int NWNX_Dialog_GetCurrentNodeIndex() +{ + string sFunc = "GetCurrentNodeIndex"; + + NWNX_CallFunction(NWNX_Dialog, sFunc); + return NWNX_GetReturnValueInt(NWNX_Dialog, sFunc); +} + +string NWNX_Dialog_GetCurrentNodeText(int language=NWNX_DIALOG_LANGUAGE_ENGLISH, int gender=GENDER_MALE) +{ + string sFunc = "GetCurrentNodeText"; + + NWNX_PushArgumentInt(NWNX_Dialog, sFunc, gender); + NWNX_PushArgumentInt(NWNX_Dialog, sFunc, language); + NWNX_CallFunction(NWNX_Dialog, sFunc); + return NWNX_GetReturnValueString(NWNX_Dialog, sFunc); +} + +void NWNX_Dialog_SetCurrentNodeText(string text, int language=NWNX_DIALOG_LANGUAGE_ENGLISH, int gender=GENDER_MALE) +{ + string sFunc = "SetCurrentNodeText"; + + NWNX_PushArgumentInt(NWNX_Dialog, sFunc, gender); + NWNX_PushArgumentInt(NWNX_Dialog, sFunc, language); + NWNX_PushArgumentString(NWNX_Dialog, sFunc, text); + NWNX_CallFunction(NWNX_Dialog, sFunc); +} + +void NWNX_Dialog_End(object oObject) +{ + string sFunc = "End"; + + NWNX_PushArgumentObject(NWNX_Dialog, sFunc, oObject); + NWNX_CallFunction(NWNX_Dialog, sFunc); +} diff --git a/nwnds_module/nwnx_effect.nss b/nwnds_module/nwnx_effect.nss new file mode 100644 index 000000000..fdc61035b --- /dev/null +++ b/nwnds_module/nwnx_effect.nss @@ -0,0 +1,259 @@ +/// @addtogroup effect Effect +/// @brief Utility functions to manipulate the builtin effect type. +/// @{ +/// @file nwnx_effect.nss +#include "nwnx" + +const string NWNX_Effect = "NWNX_Effect"; ///< @private + +/// An unpacked effect +struct NWNX_EffectUnpacked +{ + int nType; ///< @todo Describe + int nSubType; ///< @todo Describe + + float fDuration; ///< @todo Describe + int nExpiryCalendarDay; ///< @todo Describe + int nExpiryTimeOfDay; ///< @todo Describe + + object oCreator; ///< @todo Describe + int nSpellId; ///< @todo Describe + int bExpose; ///< @todo Describe + int bShowIcon; ///< @todo Describe + int nCasterLevel; ///< @todo Describe + + effect eLinkLeft; ///< @todo Describe + int bLinkLeftValid; ///< @todo Describe + effect eLinkRight; ///< @todo Describe + int bLinkRightValid; ///< @todo Describe + + int nNumIntegers; ///< @todo Describe + int nParam0; ///< @todo Describe + int nParam1; ///< @todo Describe + int nParam2; ///< @todo Describe + int nParam3; ///< @todo Describe + int nParam4; ///< @todo Describe + int nParam5; ///< @todo Describe + int nParam6; ///< @todo Describe + int nParam7; ///< @todo Describe + float fParam0; ///< @todo Describe + float fParam1; ///< @todo Describe + float fParam2; ///< @todo Describe + float fParam3; ///< @todo Describe + string sParam0; ///< @todo Describe + string sParam1; ///< @todo Describe + string sParam2; ///< @todo Describe + string sParam3; ///< @todo Describe + string sParam4; ///< @todo Describe + string sParam5; ///< @todo Describe + object oParam0; ///< @todo Describe + object oParam1; ///< @todo Describe + object oParam2; ///< @todo Describe + object oParam3; ///< @todo Describe + vector vParam0; ///< @todo Describe + vector vParam1; ///< @todo Describe + + string sTag; ///< @todo Describe +}; + +/// @brief Convert native effect type to unpacked structure. +/// @param e The effect to convert. +/// @return A constructed NWNX_EffectUnpacked. +struct NWNX_EffectUnpacked NWNX_Effect_UnpackEffect(effect e); + +/// @brief Convert unpacked effect structure to native type. +/// @param e The NWNX_EffectUnpacked structure to convert. +/// @return The effect. +effect NWNX_Effect_PackEffect(struct NWNX_EffectUnpacked e); + +/// @brief Set a script with optional data that runs when an effect expires +/// @param e The effect. +/// @param script The script to run when the effect expires. +/// @param data Any other data you wish to send back to the script. +/// @remark OBJECT_SELF in the script is the object the effect is applied to. +/// @note Only works for TEMPORARY and PERMANENT effects applied to an object. +effect NWNX_Effect_SetEffectExpiredScript(effect e, string script, string data = ""); + +/// @brief Get the data set with NWNX_Effect_SetEffectExpiredScript() +/// @note Should only be called from a script set with NWNX_Effect_SetEffectExpiredScript(). +/// @return The data attached to the effect. +string NWNX_Effect_GetEffectExpiredData(); + +/// @brief Get the effect creator. +/// @note Should only be called from a script set with NWNX_Effect_SetEffectExpiredScript(). +/// @return The object from which the effect originated. +object NWNX_Effect_GetEffectExpiredCreator(); + +/// @brief replace an already applied effect on an object +/// Only duration, subtype, tag and spell related fields can be overwritten. +/// @note eNew and eOld need to have the same type. +/// @return Number of internal effects updated. +int NWNX_Effect_ReplaceEffect(object obj, effect eOld, effect eNew); + +/// @} + +struct NWNX_EffectUnpacked NWNX_Effect_UnpackEffect(effect e) +{ + string sFunc = "UnpackEffect"; + + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, e); + NWNX_CallFunction(NWNX_Effect, sFunc); + + struct NWNX_EffectUnpacked n; + n.sTag = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + + float fZ = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + float fY = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + float fX = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.vParam1 = Vector(fX, fY, fZ); + fZ = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + fY = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + fX = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.vParam0 = Vector(fX, fY, fZ); + n.oParam3 = NWNX_GetReturnValueObject(NWNX_Effect, sFunc); + n.oParam2 = NWNX_GetReturnValueObject(NWNX_Effect, sFunc); + n.oParam1 = NWNX_GetReturnValueObject(NWNX_Effect, sFunc); + n.oParam0 = NWNX_GetReturnValueObject(NWNX_Effect, sFunc); + n.sParam5 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.sParam4 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.sParam3 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.sParam2 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.sParam1 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.sParam0 = NWNX_GetReturnValueString(NWNX_Effect, sFunc); + n.fParam3 = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.fParam2 = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.fParam1 = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.fParam0 = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + n.nParam7 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam6 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam5 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam4 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam3 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam2 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam1 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nParam0 = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nNumIntegers = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + + n.bLinkRightValid = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.eLinkRight = NWNX_GetReturnValueEffect(NWNX_Effect, sFunc); + n.bLinkLeftValid = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.eLinkLeft = NWNX_GetReturnValueEffect(NWNX_Effect, sFunc); + + n.nCasterLevel = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.bShowIcon = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.bExpose = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nSpellId = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.oCreator = NWNX_GetReturnValueObject(NWNX_Effect, sFunc); + + n.nExpiryTimeOfDay = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nExpiryCalendarDay = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.fDuration = NWNX_GetReturnValueFloat(NWNX_Effect, sFunc); + + n.nSubType = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + n.nType = NWNX_GetReturnValueInt(NWNX_Effect, sFunc); + + return n; +} +effect NWNX_Effect_PackEffect(struct NWNX_EffectUnpacked e) +{ + string sFunc = "PackEffect"; + + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nType); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nSubType); + + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.fDuration); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nExpiryCalendarDay); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nExpiryTimeOfDay); + + NWNX_PushArgumentObject(NWNX_Effect, sFunc, e.oCreator); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nSpellId); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.bExpose); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.bShowIcon); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nCasterLevel); + + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, e.eLinkLeft); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.bLinkLeftValid); + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, e.eLinkRight); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.bLinkRightValid); + + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nNumIntegers); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam0); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam1); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam2); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam3); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam4); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam5); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam6); + NWNX_PushArgumentInt(NWNX_Effect, sFunc, e.nParam7); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.fParam0); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.fParam1); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.fParam2); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.fParam3); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam0); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam1); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam2); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam3); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam4); + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sParam5); + NWNX_PushArgumentObject(NWNX_Effect, sFunc, e.oParam0); + NWNX_PushArgumentObject(NWNX_Effect, sFunc, e.oParam1); + NWNX_PushArgumentObject(NWNX_Effect, sFunc, e.oParam2); + NWNX_PushArgumentObject(NWNX_Effect, sFunc, e.oParam3); + + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam0.x); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam0.y); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam0.z); + + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam1.x); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam1.y); + NWNX_PushArgumentFloat(NWNX_Effect, sFunc, e.vParam1.z); + + NWNX_PushArgumentString(NWNX_Effect, sFunc, e.sTag); + + NWNX_CallFunction(NWNX_Effect, sFunc); + return NWNX_GetReturnValueEffect(NWNX_Effect, sFunc); +} + +effect NWNX_Effect_SetEffectExpiredScript(effect e, string script, string data = "") +{ + string sFunc = "SetEffectExpiredScript"; + + NWNX_PushArgumentString(NWNX_Effect, sFunc, data); + NWNX_PushArgumentString(NWNX_Effect, sFunc, script); + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, e); + + NWNX_CallFunction(NWNX_Effect, sFunc); + + return NWNX_GetReturnValueEffect(NWNX_Effect, sFunc); +} + +string NWNX_Effect_GetEffectExpiredData() +{ + string sFunc = "GetEffectExpiredData"; + + NWNX_CallFunction(NWNX_Effect, sFunc); + + return NWNX_GetReturnValueString(NWNX_Effect, sFunc); +} + +object NWNX_Effect_GetEffectExpiredCreator() +{ + string sFunc = "GetEffectExpiredCreator"; + + NWNX_CallFunction(NWNX_Effect, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Effect, sFunc); +} + +int NWNX_Effect_ReplaceEffect(object obj, effect eOld, effect eNew) +{ + string sFunc = "ReplaceEffect"; + + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, eNew); + NWNX_PushArgumentEffect(NWNX_Effect, sFunc, eOld); + NWNX_PushArgumentObject(NWNX_Effect, sFunc, obj); + + NWNX_CallFunction(NWNX_Effect, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Effect, sFunc); +} diff --git a/nwnds_module/nwnx_elc.nss b/nwnds_module/nwnx_elc.nss new file mode 100644 index 000000000..050496331 --- /dev/null +++ b/nwnds_module/nwnx_elc.nss @@ -0,0 +1,244 @@ +/// @addtogroup elc ELC +/// @brief Replacement for ValidateCharacter: ELC & ILR +/// @{ +/// @file nwnx_elc.nss +#include "nwnx" + +const string NWNX_ELC = "NWNX_ELC"; ///< @private + + +/// @anchor elc_fail_type +/// @name ELC Failure Types +/// @{ +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_NONE = 0; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_CHARACTER = 1; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_ITEM = 2; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_SKILL = 3; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_FEAT = 4; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_SPELL = 5; +const int NWNX_ELC_VALIDATION_FAILURE_TYPE_CUSTOM = 6; +/// @} + +/// @anchor elc_fail_subtype +/// @name ELC Failure Subtypes +/// @note By default these constants are commented out to avoid a +/// limitation on constants. Uncomment them as needed. +/// @{ +const int NWNX_ELC_SUBTYPE_NONE = 0; +/* +const int NWNX_ELC_SUBTYPE_SERVER_LEVEL_RESTRICTION = 1; +const int NWNX_ELC_SUBTYPE_LEVEL_HACK = 2; +const int NWNX_ELC_SUBTYPE_COLORED_NAME = 3; +const int NWNX_ELC_SUBTYPE_UNIDENTIFIED_EQUIPPED_ITEM = 4; +const int NWNX_ELC_SUBTYPE_MIN_EQUIP_LEVEL = 5; +const int NWNX_ELC_SUBTYPE_NON_PC_CHARACTER = 6; +const int NWNX_ELC_SUBTYPE_DM_CHARACTER = 7; +const int NWNX_ELC_SUBTYPE_NON_PLAYER_RACE = 8; +const int NWNX_ELC_SUBTYPE_NON_PLAYER_CLASS = 9; +const int NWNX_ELC_SUBTYPE_CLASS_LEVEL_RESTRICTION = 10; +const int NWNX_ELC_SUBTYPE_PRESTIGE_CLASS_REQUIREMENTS = 11; +const int NWNX_ELC_SUBTYPE_CLASS_ALIGNMENT_RESTRICTION = 12; +const int NWNX_ELC_SUBTYPE_STARTING_ABILITY_VALUE_MAX = 13; +const int NWNX_ELC_SUBTYPE_ABILITY_POINT_BUY_SYSTEM_CALCULATION = 14; +const int NWNX_ELC_SUBTYPE_CLASS_SPELLCASTER_INVALID_PRIMARY_STAT = 15; +const int NWNX_ELC_SUBTYPE_EPIC_LEVEL_FLAG = 16; +const int NWNX_ELC_SUBTYPE_TOO_MANY_HITPOINTS = 17; +const int NWNX_ELC_SUBTYPE_UNUSABLE_SKILL = 18; +const int NWNX_ELC_SUBTYPE_NOT_ENOUGH_SKILLPOINTS = 19; +const int NWNX_ELC_SUBTYPE_INVALID_NUM_RANKS_IN_CLASS_SKILL = 20; +const int NWNX_ELC_SUBTYPE_INVALID_NUM_RANKS_IN_NON_CLASS_SKILL = 21; +const int NWNX_ELC_SUBTYPE_INVALID_NUM_REMAINING_SKILL_POINTS = 22; +const int NWNX_ELC_SUBTYPE_INVALID_FEAT = 23; +const int NWNX_ELC_SUBTYPE_FEAT_REQUIRED_SPELL_LEVEL_NOT_MET = 24; +const int NWNX_ELC_SUBTYPE_FEAT_REQUIRED_BASE_ATTACK_BONUS_NOT_MET = 25; +const int NWNX_ELC_SUBTYPE_FEAT_REQUIRED_ABILITY_VALUE_NOT_MET = 26; +const int NWNX_ELC_SUBTYPE_FEAT_REQUIRED_SKILL_NOT_MET = 27; +const int NWNX_ELC_SUBTYPE_FEAT_REQUIRED_FEAT_NOT_MET = 28; +const int NWNX_ELC_SUBTYPE_TOO_MANY_FEATS_THIS_LEVEL = 29; +const int NWNX_ELC_SUBTYPE_FEAT_NOT_AVAILABLE_TO_CLASS = 30; +const int NWNX_ELC_SUBTYPE_FEAT_IS_NORMAL_FEAT_ONLY = 31; +const int NWNX_ELC_SUBTYPE_FEAT_IS_BONUS_FEAT_ONLY = 32; +const int NWNX_ELC_SUBTYPE_SPELL_INVALID_SPELL_GAIN_WIZARD = 33; +const int NWNX_ELC_SUBTYPE_SPELL_INVALID_SPELL_GAIN_BARD_SORCERER = 34; +const int NWNX_ELC_SUBTYPE_SPELL_INVALID_SPELL_GAIN_OTHER_CLASSES = 35; +const int NWNX_ELC_SUBTYPE_INVALID_SPELL = 36; +const int NWNX_ELC_SUBTYPE_SPELL_INVALID_SPELL_LEVEL = 37; +const int NWNX_ELC_SUBTYPE_SPELL_MINIMUM_ABILITY = 40; +const int NWNX_ELC_SUBTYPE_SPELL_RESTRICTED_SPELL_SCHOOL = 41; +const int NWNX_ELC_SUBTYPE_SPELL_ALREADY_KNOWN = 42; +const int NWNX_ELC_SUBTYPE_SPELL_WIZARD_EXCEEDS_NUMSPELLS_TO_ADD = 43; +const int NWNX_ELC_SUBTYPE_ILLEGAL_REMOVED_SPELL = 44; +const int NWNX_ELC_SUBTYPE_REMOVED_NOT_KNOWN_SPELL = 45; +const int NWNX_ELC_SUBTYPE_INVALID_NUM_SPELLS = 46; +const int NWNX_ELC_SUBTYPE_SPELL_LIST_COMPARISON = 47; +const int NWNX_ELC_SUBTYPE_SKILL_LIST_COMPARISON = 48; +const int NWNX_ELC_SUBTYPE_FEAT_LIST_COMPARISON = 49; +const int NWNX_ELC_SUBTYPE_MISC_SAVING_THROW = 50; +const int NWNX_ELC_SUBTYPE_NUM_FEAT_COMPARISON = 51; + */ +/// @} + +/// @brief Sets the script that runs whenever an ELC validation failure happens +/// @param sScript The script name. +void NWNX_ELC_SetELCScript(string sScript); + +/// @brief Enables a custom ELC Check that will call the ELC Script with the +/// NWNX_ELC_VALIDATION_FAILURE_TYPE_CUSTOM type. +/// @param bEnabled TRUE to use this check. +/// @note Only runs if you have an ELC script set, be sure to skip this check +/// if a player doesn't fail your custom check otherwise they won't be able to log in +void NWNX_ELC_EnableCustomELCCheck(int bEnabled); + +/// @brief Skip an ELC Validation Failure Event +/// @note Only to be called in the ELC Script +void NWNX_ELC_SkipValidationFailure(); + +/// @brief Get the validation failure type +/// @return A @ref elc_fail_type "Validation Failure Type" +/// @note Only to be called in the ELC Script +int NWNX_ELC_GetValidationFailureType(); + +/// @brief Get the validation failure subtype +/// @return A @ref elc_fail_subtype "Validation Failure Subtype" +/// @note Only to be called in the ELC Script +int NWNX_ELC_GetValidationFailureSubType(); + +/// @brief Get the failure message +/// @return The talk table strref the player receives. +/// @note Only to be called in the ELC Script +int NWNX_ELC_GetValidationFailureMessageStrRef(); + +/// @brief Set the failure message +/// @param nStrRef The talk table strref the player receives, must be > 0. +/// @note Only to be called in the ELC Script +void NWNX_ELC_SetValidationFailureMessageStrRef(int nStrRef); + +/// @brief Get the item that failed ILR validation +/// @return The object that caused the ILR validation failure. Returns OBJECT_INVALID on error. +/// @note Only to be called in the ELC Script during a +/// NWNX_ELC_VALIDATION_FAILURE_TYPE_ITEM validation failure. +object NWNX_ELC_GetValidationFailureItem(); + +/// @brief Get the character level at which the validation failure occurred +/// @return The character level or -1 on error. +/// @remark May not always return a level, depending on where the failure occurred. +/// @note Only to be called in the ELC Script +int NWNX_ELC_GetValidationFailureLevel(); + +/// @brief Get the ID of the skill that failed ELC validation +/// @return The skill ID or -1 on error. +/// @remark May not always return a skill id, depending on the validation failure subtype. +/// @note Only to be called in the ELC Script during a +/// NWNX_ELC_VALIDATION_FAILURE_TYPE_SKILL validation failure. +int NWNX_ELC_GetValidationFailureSkillID(); + +/// @brief Get the ID of the feat that failed ELC validation +/// @return The feat ID or -1 on error +/// @remark May not always return a feat id, depending on the validation failure subtype. +/// @note Only to be called in the ELC Script during a +/// NWNX_ELC_VALIDATION_FAILURE_TYPE_FEAT validation failure. +int NWNX_ELC_GetValidationFailureFeatID(); + +/// @brief Get the ID of the spell that failed ELC validation +/// @return The spell ID or -1 on error +/// @remark May not always return a spell id, depending on the validation failure subtype. +/// @note Only to be called in the ELC Script during a +/// NWNX_ELC_VALIDATION_FAILURE_TYPE_SPELL validation failure. +int NWNX_ELC_GetValidationFailureSpellID(); + +/// @} + +void NWNX_ELC_SetELCScript(string sScript) +{ + string sFunc = "SetELCScript"; + + NWNX_PushArgumentString(NWNX_ELC, sFunc, sScript); + NWNX_CallFunction(NWNX_ELC, sFunc); +} + +void NWNX_ELC_EnableCustomELCCheck(int bEnabled) +{ + string sFunc = "EnableCustomELCCheck"; + + NWNX_PushArgumentInt(NWNX_ELC, sFunc, bEnabled); + NWNX_CallFunction(NWNX_ELC, sFunc); +} + +void NWNX_ELC_SkipValidationFailure() +{ + string sFunc = "SkipValidationFailure"; + + NWNX_CallFunction(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureType() +{ + string sFunc = "GetValidationFailureType"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureSubType() +{ + string sFunc = "GetValidationFailureSubType"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureMessageStrRef() +{ + string sFunc = "GetValidationFailureMessageStrRef"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +void NWNX_ELC_SetValidationFailureMessageStrRef(int nStrRef) +{ + string sFunc = "SetValidationFailureMessageStrRef"; + + NWNX_PushArgumentInt(NWNX_ELC, sFunc, nStrRef); + NWNX_CallFunction(NWNX_ELC, sFunc); +} + +object NWNX_ELC_GetValidationFailureItem() +{ + string sFunc = "GetValidationFailureItem"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueObject(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureLevel() +{ + string sFunc = "GetValidationFailureLevel"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureSkillID() +{ + string sFunc = "GetValidationFailureSkillID"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureFeatID() +{ + string sFunc = "GetValidationFailureFeatID"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} + +int NWNX_ELC_GetValidationFailureSpellID() +{ + string sFunc = "GetValidationFailureSpellID"; + + NWNX_CallFunction(NWNX_ELC, sFunc); + return NWNX_GetReturnValueInt(NWNX_ELC, sFunc); +} diff --git a/nwnds_module/nwnx_encounter.nss b/nwnds_module/nwnx_encounter.nss new file mode 100644 index 000000000..8857184f7 --- /dev/null +++ b/nwnds_module/nwnx_encounter.nss @@ -0,0 +1,285 @@ +/// @addtogroup encounter Encounter +/// @brief Functions exposing additional encounter properties. +/// @{ +/// @file nwnx_encounter.nss +#include "nwnx" + +const string NWNX_Encounter = "NWNX_Encounter"; ///< @private + +/// @brief A creature list entry for an encounter. +struct NWNX_Encounter_CreatureListEntry +{ + string resref; ///< The resref. + float challengeRating; ///< The challenge rating. + int unique; ///< Creature will be unique to the encounter. + int alreadyUsed; //< Creature has already been used. +}; + + +/// @brief Get the number of creatures in the encounter list +/// @param encounter The encounter object. +/// @return The number of creatures in the encounter list. +int NWNX_Encounter_GetNumberOfCreaturesInEncounterList(object encounter); + +/// @brief Gets the encounter creature list entry at the specified index +/// @param encounter The encounter object. +/// @param index The index of the creature in the encounter list. +/// @return An NWNX_Encounter_CreatureListEntry. +struct NWNX_Encounter_CreatureListEntry NWNX_Encounter_GetEncounterCreatureByIndex(object encounter, int index); + +/// @brief Set the encounter creature list entry at the specified index +/// @param encounter The encounter object. +/// @param index The index of the creature in the encounter list. +/// @param creatureEntry The NWNX_Encounter_CreatureListEntry. +void NWNX_Encounter_SetEncounterCreatureByIndex(object encounter, int index, struct NWNX_Encounter_CreatureListEntry creatureEntry); + +/// @brief Get the faction id of encounter +/// @param encounter The encounter object. +/// @return The faction id. +int NWNX_Encounter_GetFactionId(object encounter); + +/// @brief Set the faction id of encounter. +/// @param encounter The encounter object. +/// @param factionId The faction id. +void NWNX_Encounter_SetFactionId(object encounter, int factionId); + +/// @brief Get if encounter is player triggered only. +/// @param encounter The encounter object. +/// @return TRUE if encounter is player triggered only. +int NWNX_Encounter_GetPlayerTriggeredOnly(object encounter); + +/// @brief Set if encounter is player triggered only. +/// @param encounter The encounter object. +/// @param playerTriggeredOnly TRUE/FALSE +void NWNX_Encounter_SetPlayerTriggeredOnly(object encounter, int playerTriggeredOnly); + +/// @brief Get the reset time of encounter. +/// @param encounter The encounter object. +/// @return The seconds the encounter is defined to reset. +int NWNX_Encounter_GetResetTime(object encounter); + +/// @brief Set the reset time of encounter. +/// @param encounter The encounter object. +/// @param resetTime The seconds the encounter will reset. +void NWNX_Encounter_SetResetTime(object encounter, int resetTime); + +/// @brief Get the number of spawn points of encounter. +/// @param encounter The encounter object. +/// @return The count of the spawn points for the encounter. +int NWNX_Encounter_GetNumberOfSpawnPoints(object encounter); + +/// @brief Gets the spawn point list entry at the specified index +/// @param encounter The encounter object. +/// @param index The index of the spawn point in the encounter list. +/// @return Location of spawn point. +location NWNX_Encounter_GetSpawnPointByIndex(object encounter, int index); + +/// @brief Get the minimum amount of creatures that encounter will spawn. +/// @param encounter The encounter object. +/// @return the minimal amount. +int NWNX_Encounter_GetMinNumSpawned(object encounter); + +/// @brief Get the maximum amount of creatures that encounter will spawn. +/// @param encounter The encounter object. +/// @return the maximal amount. +int NWNX_Encounter_GetMaxNumSpawned(object encounter); + +/// @brief Get the current number of creatures that are spawned and alive +/// @param encounter The encounter object. +/// @return amount of creatures +int NWNX_Encounter_GetCurrentNumSpawned(object encounter); + +/// @brief Get the geometry of an encounter +/// @param oEncounter: The encounter object. +/// @return A string of vertex positions. +string NWNX_Encounter_GetGeometry(object oEncounter); + +/// @brief Set the geometry of an encounter with a list of vertex positions +/// @param oTrigger The encounter object. +/// @param sGeometry Needs to be in the following format -> {x.x, y.y, z.z} or {x.x, y.y} +/// Example Geometry: "{1.0, 1.0, 0.0}{4.0, 1.0, 0.0}{4.0, 4.0, 0.0}{1.0, 4.0, 0.0}" +/// +/// @remark The Z position is optional and will be calculated dynamically based +/// on terrain height if it's not provided. +/// +/// @remark The minimum number of vertices is 3. +void NWNX_Encounter_SetGeometry(object oTrigger, string sGeometry); + +/// @} + +int NWNX_Encounter_GetNumberOfCreaturesInEncounterList(object encounter) +{ + string sFunc = "GetNumberOfCreaturesInEncounterList"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +struct NWNX_Encounter_CreatureListEntry NWNX_Encounter_GetEncounterCreatureByIndex(object encounter, int index) +{ + string sFunc = "GetEncounterCreatureByIndex"; + struct NWNX_Encounter_CreatureListEntry creatureEntry; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, index); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + + NWNX_CallFunction(NWNX_Encounter, sFunc); + + creatureEntry.alreadyUsed = NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); + creatureEntry.unique = NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); + creatureEntry.challengeRating = NWNX_GetReturnValueFloat(NWNX_Encounter, sFunc); + creatureEntry.resref = NWNX_GetReturnValueString(NWNX_Encounter, sFunc); + + return creatureEntry; +} + +void NWNX_Encounter_SetEncounterCreatureByIndex(object encounter, int index, struct NWNX_Encounter_CreatureListEntry creatureEntry) +{ + string sFunc = "SetEncounterCreatureByIndex"; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, creatureEntry.alreadyUsed); + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, creatureEntry.unique); + NWNX_PushArgumentFloat(NWNX_Encounter, sFunc, creatureEntry.challengeRating); + NWNX_PushArgumentString(NWNX_Encounter, sFunc, creatureEntry.resref); + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, index); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + + NWNX_CallFunction(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetFactionId(object encounter) +{ + string sFunc = "GetFactionId"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +void NWNX_Encounter_SetFactionId(object encounter, int factionId) +{ + string sFunc = "SetFactionId"; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, factionId); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + + NWNX_CallFunction(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetPlayerTriggeredOnly(object encounter) +{ + string sFunc = "GetPlayerTriggeredOnly"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +void NWNX_Encounter_SetPlayerTriggeredOnly(object encounter, int playerTriggeredOnly) +{ + string sFunc = "SetPlayerTriggeredOnly"; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, playerTriggeredOnly); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + + NWNX_CallFunction(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetResetTime(object encounter) +{ + string sFunc = "GetResetTime"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +void NWNX_Encounter_SetResetTime(object encounter, int resetTime) +{ + string sFunc = "SetResetTime"; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, resetTime); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + + NWNX_CallFunction(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetNumberOfSpawnPoints(object encounter) +{ + string sFunc = "GetNumberOfSpawnPoints"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +location NWNX_Encounter_GetSpawnPointByIndex(object encounter, int index) +{ + string sFunc = "GetSpawnPointByIndex"; + + NWNX_PushArgumentInt(NWNX_Encounter, sFunc, index); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + float o = NWNX_GetReturnValueFloat(NWNX_Encounter, sFunc); + float z = NWNX_GetReturnValueFloat(NWNX_Encounter, sFunc); + float y = NWNX_GetReturnValueFloat(NWNX_Encounter, sFunc); + float x = NWNX_GetReturnValueFloat(NWNX_Encounter, sFunc); + + return Location(GetArea(encounter), Vector(x, y, z), o); +} + +int NWNX_Encounter_GetMinNumSpawned(object encounter) +{ + string sFunc = "GetMinNumSpawned"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetMaxNumSpawned(object encounter) +{ + string sFunc = "GetMaxNumSpawned"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +int NWNX_Encounter_GetCurrentNumSpawned(object encounter) +{ + string sFunc = "GetCurrentNumSpawned"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, encounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Encounter, sFunc); +} + +string NWNX_Encounter_GetGeometry(object oEncounter) +{ + string sFunc = "GetGeometry"; + + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, oEncounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); + + return NWNX_GetReturnValueString(NWNX_Encounter, sFunc); +} + +void NWNX_Encounter_SetGeometry(object oEncounter, string sGeometry) +{ + string sFunc = "SetGeometry"; + + NWNX_PushArgumentString(NWNX_Encounter, sFunc, sGeometry); + NWNX_PushArgumentObject(NWNX_Encounter, sFunc, oEncounter); + NWNX_CallFunction(NWNX_Encounter, sFunc); +} diff --git a/nwnds_module/nwnx_events.nss b/nwnds_module/nwnx_events.nss new file mode 100644 index 000000000..cd22c0347 --- /dev/null +++ b/nwnds_module/nwnx_events.nss @@ -0,0 +1,1590 @@ +/// @addtogroup events Events +/// @brief Provides an interface for plugins to create event-based systems, and exposes some events through that interface. +/// @{ +/// @file nwnx_events.nss +#include "nwnx" + +const string NWNX_Events = "NWNX_Events"; ///< @private + +/** + # Events +__________________________________________ + ## Associate Events + - NWNX_ON_ADD_ASSOCIATE_BEFORE + - NWNX_ON_ADD_ASSOCIATE_AFTER + - NWNX_ON_REMOVE_ASSOCIATE_BEFORE + - NWNX_ON_REMOVE_ASSOCIATE_AFTER + + `OBJECT_SELF` = The owner of the associate. + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ASSOCIATE_OBJECT_ID | object | Convert to object with StringToObject() + +_______________________________________ + ## Stealth Events + - NWNX_ON_STEALTH_ENTER_BEFORE + - NWNX_ON_STEALTH_ENTER_AFTER + - NWNX_ON_STEALTH_EXIT_BEFORE + - NWNX_ON_STEALTH_EXIT_AFTER + + `OBJECT_SELF` = The creature entering or exiting stealth. + + @note NWNX_ON_{ENTER|EXIT}_STEALTH_{BEFORE|AFTER} has been deprecated. Please use these new event names. +_______________________________________ + ## Detect Events + - NWNX_ON_DETECT_ENTER_BEFORE + - NWNX_ON_DETECT_ENTER_AFTER + - NWNX_ON_DETECT_EXIT_BEFORE + - NWNX_ON_DETECT_EXIT_AFTER + + `OBJECT_SELF` = The creature entering or exiting detect mode. + +_______________________________________ + ## Examine Events + - NWNX_ON_EXAMINE_OBJECT_BEFORE + - NWNX_ON_EXAMINE_OBJECT_AFTER + + `OBJECT_SELF` = The player examining the object + + Event Data Tag | Type | Notes + ----------------------|--------|------- + EXAMINEE_OBJECT_ID | object | Convert to object with StringToObject() + TRAP_EXAMINE_SUCCESS | int | For trap examine only, whether the examine succeeded + +_______________________________________ + ## Faction Events + - NWNX_ON_SET_NPC_FACTION_REPUTATION_BEFORE + - NWNX_ON_SET_NPC_FACTION_REPUTATION_AFTER + + `OBJECT_SELF` = The module + + Event Data Tag | Type | Notes + ----------------------|--------|------- + FACTION_ID | int | Not the STANDARD_FACTION_* constants. See nwnx_creature->GetFaction(). + SUBJECT_FACTION_ID | int | Not the STANDARD_FACTION_* constants. See nwnx_creature->GetFaction(). + PREVIOUS_REPUTATION | int | + NEW_REPUTATION | int | Not yet clamped between 0-100. In the AFTER event, this will equal the EventResult set in the BEFORE event. + +_______________________________________ + ## Validate Use Item Events + - NWNX_ON_VALIDATE_USE_ITEM_BEFORE + - NWNX_ON_VALIDATE_USE_ITEM_AFTER + + `OBJECT_SELF` = The creature using the item + + Event Data Tag | Type | Notes | + ------------------------|--------|-------| + ITEM_OBJECT_ID | object | Convert to object with StringToObject()| + BEFORE_RESULT | int | TRUE/FALSE, only in _AFTER events| + + @note The event result should be one of: + "0" - Equip denied + "1" - Equip okay + "2" - Swap currently equipped item + "3" - Unequip items in both hands before equipping + @note Setting the result of this event will NOT prevent the item from being equipped, only used (e.g. scrolls/wands). See the "NWNX_ON_VALIDATE_ITEM_EQUIP_*" events to control equip behaviour. + @note If the BEFORE event is not skipped, BEFORE_RESULT is the value of running the function normally. Otherwise, this is the set result value. + +_______________________________________ + ## Use Item Events + - NWNX_ON_USE_ITEM_BEFORE + - NWNX_ON_USE_ITEM_AFTER + + `OBJECT_SELF` = The creature using the item + + Event Data Tag | Type | Notes | + ------------------------|--------|-------| + ITEM_OBJECT_ID | object | Convert to object with StringToObject()| + TARGET_OBJECT_ID | object | Convert to object with StringToObject()| + ITEM_PROPERTY_INDEX | int | | + ITEM_SUB_PROPERTY_INDEX | int | | + TARGET_POSITION_X | float | | + TARGET_POSITION_Y | float | | + TARGET_POSITION_Z | float | | + USE_CHARGES | int | | + + @note You can set the event result to "0" (send feedback to the client that the item cannot be used, default) + or "1" to suppress that feedback. + +_______________________________________ + ## Item Container Events + - NWNX_ON_ITEM_INVENTORY_OPEN_BEFORE + - NWNX_ON_ITEM_INVENTORY_OPEN_AFTER + - NWNX_ON_ITEM_INVENTORY_CLOSE_BEFORE + - NWNX_ON_ITEM_INVENTORY_CLOSE_AFTER + + `OBJECT_SELF` = The container + + Event Data Tag | Type | Notes + ----------------------|--------|------- + OWNER | object |Convert to object with StringToObject() + +_______________________________________ + ## Ammunition Reload Events + - NWNX_ON_ITEM_AMMO_RELOAD_BEFORE + - NWNX_ON_ITEM_AMMO_RELOAD_AFTER + + `OBJECT_SELF` = The creature whose inventory we're searching for the item type + + Event Data Tag | Type | Notes + ----------------------|------|------- + BASE_ITEM_ID | int | The base item type being sought (arrow, bolt, bullet) + BASE_ITEM_NTH | int | Find the Nth instance of this item + ACTION_RESULT | int | The object that was determined in BEFORE (only in after) + +_______________________________________ + ## Scroll Learn Events + - NWNX_ON_ITEM_SCROLL_LEARN_BEFORE + - NWNX_ON_ITEM_SCROLL_LEARN_AFTER + + `OBJECT_SELF` = The creature learning the scroll + + Event Data Tag | Type | Notes + ----------------------|--------|------- + SCROLL | object | Convert to object with StringToObject() + RESULT | int | Returns TRUE in the _AFTER if the learning was successful, FALSE otherwise + +_______________________________________ + ## Validate Item Equip Events + - NWNX_ON_VALIDATE_ITEM_EQUIP_BEFORE + - NWNX_ON_VALIDATE_ITEM_EQUIP_AFTER + + `OBJECT_SELF` = The creature trying to equip the item + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + ITEM_OBJECT_ID | object | Convert to object with StringToObject()| + SLOT | int | INVENTORY_SLOT_* Constant| + BEFORE_RESULT | int | TRUE/FALSE, only in _AFTER events| + + @note Manually setting the result of this event will skip all game checks for item slot validity. The client will block incompatible types (weapons into armor slots) in the GUI, but this will work using ActionEquipItem(). + @note To show this item as unusable to the PC (red in the inventory), use in combination with the "NWNX_ON_VALIDATE_USE_ITEM_*" events. + @note If the BEFORE event is not skipped, BEFORE_RESULT is the value of running the function normally. Otherwise, this is the set result value. + +_______________________________________ + ## Item Equip Events + - NWNX_ON_ITEM_EQUIP_BEFORE + - NWNX_ON_ITEM_EQUIP_AFTER + + `OBJECT_SELF` = The creature equipping the item + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + ITEM | object | Convert to object with StringToObject()| + SLOT | int | | + +_______________________________________ + ## Item Unequip Events + - NWNX_ON_ITEM_UNEQUIP_BEFORE + - NWNX_ON_ITEM_UNEQUIP_AFTER + + `OBJECT_SELF` = The creature unequipping the item + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ITEM | object | Convert to object with StringToObject() + + @note These events do not trigger when equipment is replaced by equipping another item. +_______________________________________ + ## Item Destroy Events + - NWNX_ON_ITEM_DESTROY_OBJECT_BEFORE + - NWNX_ON_ITEM_DESTROY_OBJECT_AFTER + - NWNX_ON_ITEM_DECREMENT_STACKSIZE_BEFORE + - NWNX_ON_ITEM_DECREMENT_STACKSIZE_AFTER + + `OBJECT_SELF` = The item triggering the event + + @note Use of `NWNX_ON_ITEM_(DESTROY_OBJECT|DECREMENT_STACKSIZE)_*` conflicts with object event handler profiling + +_______________________________________ + ## Item Use Lore To Identify Events + - NWNX_ON_ITEM_USE_LORE_BEFORE + - NWNX_ON_ITEM_USE_LORE_AFTER + + `OBJECT_SELF` = The player attempting to identify an item with their lore skill + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ITEM | object |Convert to object with StringToObject() + +_______________________________________ + ## Item Pay To Identify Events + - NWNX_ON_ITEM_PAY_TO_IDENTIFY_BEFORE + - NWNX_ON_ITEM_PAY_TO_IDENTIFY_AFTER + + `OBJECT_SELF` = The player attempting to pay to identify an item + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ITEM | object | Convert to object with StringToObject() + STORE | object | Convert to object with StringToObject() + +_______________________________________ + ## Item Split Events + - NWNX_ON_ITEM_SPLIT_BEFORE + - NWNX_ON_ITEM_SPLIT_AFTER + + `OBJECT_SELF` = The player attempting to split an item + + Event Data Tag | Type | Notes| + ----------------------|--------|-------| + ITEM | object | Convert to object with StringToObject()| + NUMBER_SPLIT_OFF | int | | + +_______________________________________ + ## Acquire Item Events + - NWNX_ON_ITEM_ACQUIRE_BEFORE + - NWNX_ON_ITEM_ACQUIRE_AFTER + + `OBJECT_SELF` = The creature trying to acquire the item + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + ITEM | object | Convert to object with StringToObject() (May be OBJECT_INVALID in the AFTER event) | + GIVER | object | Convert to object with StringToObject() (will be INVALID if picked up from ground)| + RESULT | int | Returns TRUE in the _AFTER if the acquisition was successful, FALSE otherwise + + @note This event currently only works with creatures + +_______________________________________ + ## Feat Use Events + - NWNX_ON_USE_FEAT_BEFORE + - NWNX_ON_USE_FEAT_AFTER + + `OBJECT_SELF` = The object using the feat + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + FEAT_ID | int | | + SUBFEAT_ID | int | | + TARGET_OBJECT_ID | object | Convert to object with StringToObject() | + AREA_OBJECT_ID | object | Convert to object with StringToObject() | + TARGET_POSITION_X | float | | + TARGET_POSITION_Y | float | | + TARGET_POSITION_Z | float | | + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events + +_______________________________________ + ## Has Feat Events + - NWNX_ON_HASFEAT_BEFORE + - NWNX_ON_HAS_FEAT_AFTER + + `OBJECT_SELF` = The player being checked for the feat + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + FEAT_ID | int | | + HAS_FEAT | int | Whether they truly have the feat or not | + + @note This event should definitely be used with the Event ID Whitelist, which is turned on by default + for this event. Until you add your Feat ID to the whitelist on module load this event will not function. + For example if you wish an event to fire when nwn is checking if the creature has Epic Dodge you would perform + the following functions on_module_load. + ```c + NWNX_Events_SubscribeEvent("NWNX_ON_HAS_FEAT_BEFORE", "event_has_feat"); + NWNX_Events_AddIDToWhitelist("NWNX_ON_HAS_FEAT", FEAT_EPIC_DODGE); + ``` + @warning Toggling the Whitelist to be off for this event will degrade performance. +_______________________________________ + ## DM Give Events + - NWNX_ON_DM_GIVE_GOLD_BEFORE + - NWNX_ON_DM_GIVE_GOLD_AFTER + - NWNX_ON_DM_GIVE_XP_BEFORE + - NWNX_ON_DM_GIVE_XP_AFTER + - NWNX_ON_DM_GIVE_LEVEL_BEFORE + - NWNX_ON_DM_GIVE_LEVEL_AFTER + - NWNX_ON_DM_GIVE_ALIGNMENT_BEFORE + - NWNX_ON_DM_GIVE_ALIGNMENT_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + AMOUNT | int | | + OBJECT | object | Convert to object with StringToObject() | + ALIGNMENT_TYPE | int | Only valid for `NWNX_ON_DM_GIVE_ALIGNMENT_*` | + +_______________________________________ + ## DM Spawn Object Events + - NWNX_ON_DM_SPAWN_OBJECT_BEFORE + - NWNX_ON_DM_SPAWN_OBJECT_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + AREA | object | Convert to object with StringToObject() | + OBJECT | object | Only returns a valid object in *_AFTER | + OBJECT_TYPE | int | Returns `NWNX_EVENTS_OBJECT_TYPE_*` | + POS_X | float | | + POS_Y | float | | + POS_Z | float | | + RESREF | string | The resref of the object that's being spawned. | + + @note When spawning a standard trap, the resref will be an index into traps.2da. + +_______________________________________ + ## DM Give Item Events + - NWNX_ON_DM_GIVE_ITEM_BEFORE + - NWNX_ON_DM_GIVE_ITEM_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + ITEM | object | Only returns a valid object in *_AFTER + +_______________________________________ + ## DM Multiple Object Action Events + - NWNX_ON_DM_HEAL_BEFORE + - NWNX_ON_DM_HEAL_AFTER + - NWNX_ON_DM_KILL_BEFORE + - NWNX_ON_DM_KILL_AFTER + - NWNX_ON_DM_TOGGLE_INVULNERABLE_BEFORE + - NWNX_ON_DM_TOGGLE_INVULNERABLE_AFTER + - NWNX_ON_DM_FORCE_REST_BEFORE + - NWNX_ON_DM_FORCE_REST_AFTER + - NWNX_ON_DM_LIMBO_BEFORE + - NWNX_ON_DM_LIMBO_AFTER + - NWNX_ON_DM_TOGGLE_AI_BEFORE + - NWNX_ON_DM_TOGGLE_AI_AFTER + - NWNX_ON_DM_TOGGLE_IMMORTAL_BEFORE + - NWNX_ON_DM_TOGGLE_IMMORTAL_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + NUM_TARGETS | int | The number of targets affected + TARGET_* | object | * = 1 <= NUM_TARGETS + +_______________________________________ + ## DM Single Object Action Events + - NWNX_ON_DM_GOTO_BEFORE + - NWNX_ON_DM_GOTO_AFTER + - NWNX_ON_DM_POSSESS_BEFORE + - NWNX_ON_DM_POSSESS_AFTER + - NWNX_ON_DM_POSSESS_FULL_POWER_BEFORE + - NWNX_ON_DM_POSSESS_FULL_POWER_AFTER + - NWNX_ON_DM_TOGGLE_LOCK_BEFORE + - NWNX_ON_DM_TOGGLE_LOCK_AFTER + - NWNX_ON_DM_DISABLE_TRAP_BEFORE + - NWNX_ON_DM_DISABLE_TRAP_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + + @note If `TARGET` is `OBJECT_INVALID` for `NWNX_ON_DM_POSSESS_*`, the DM is unpossessing. + +_______________________________________ + ## DM Jump Events + - NWNX_ON_DM_JUMP_TO_POINT_BEFORE + - NWNX_ON_DM_JUMP_TO_POINT_AFTER + - NWNX_ON_DM_JUMP_TARGET_TO_POINT_BEFORE + - NWNX_ON_DM_JUMP_TARGET_TO_POINT_AFTER + - NWNX_ON_DM_JUMP_ALL_PLAYERS_TO_POINT_BEFORE + - NWNX_ON_DM_JUMP_ALL_PLAYERS_TO_POINT_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + TARGET_AREA | object | Convert to object with StringToObject() | + POS_X | float | | + POS_Y | float | | + POS_Z | float | | + NUM_TARGETS | int | Only valid for NWNX_ON_DM_JUMP_TARGET_TO_POINT_* | + TARGET_* | object | * = 1 <= NUM_TARGETS, Only valid for NWNX_ON_DM_JUMP_TARGET_TO_POINT_* | + +_______________________________________ + ## DM Change Difficulty Events + - NWNX_ON_DM_CHANGE_DIFFICULTY_BEFORE + - NWNX_ON_DM_CHANGE_DIFFICULTY_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + DIFFICULTY_SETTING | int | | + +_______________________________________ + ## DM View Inventory Events + - NWNX_ON_DM_VIEW_INVENTORY_BEFORE + - NWNX_ON_DM_VIEW_INVENTORY_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + OPEN_INVENTORY | int | TRUE if opening an inventory, FALSE if closing + TARGET | object | Convert to object with StringToObject() + +_______________________________________ + ## DM Spawn Trap Events + - NWNX_ON_DM_SPAWN_TRAP_ON_OBJECT_BEFORE + - NWNX_ON_DM_SPAWN_TRAP_ON_OBJECT_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + AREA | object | Convert to object with StringToObject() + TARGET | object | Convert to object with StringToObject() + +_______________________________________ + ## DM Dump Locals Events + - NWNX_ON_DM_DUMP_LOCALS_BEFORE + - NWNX_ON_DM_DUMP_LOCALS_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TYPE | int | 0 = dm_dumplocals, 1 = dm_dumparealocals, 3 = dm_dumpmodulelocals + TARGET | object | Convert to object with StringToObject() + + Note: For TYPE 1/2, use GetArea(TARGET) or GetModule() + +_______________________________________ + ## DM PlayerDM Login/Logout Events + - NWNX_ON_DM_PLAYERDM_LOGIN_BEFORE + - NWNX_ON_DM_PLAYERDM_LOGIN_AFTER + - NWNX_ON_DM_PLAYERDM_LOGOUT_BEFORE + - NWNX_ON_DM_PLAYERDM_LOGOUT_AFTER + + `OBJECT_SELF` = The DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + PASSWORD | string | The password the DM provided, only valid for NWNX_ON_DM_PLAYERDM_LOGIN_* + +_______________________________________ + ## DM Other Events + - NWNX_ON_DM_APPEAR_BEFORE + - NWNX_ON_DM_APPEAR_AFTER + - NWNX_ON_DM_DISAPPEAR_BEFORE + - NWNX_ON_DM_DISAPPEAR_AFTER + - NWNX_ON_DM_SET_FACTION_BEFORE + - NWNX_ON_DM_SET_FACTION_AFTER + - NWNX_ON_DM_TAKE_ITEM_BEFORE + - NWNX_ON_DM_TAKE_ITEM_AFTER + - NWNX_ON_DM_SET_STAT_BEFORE + - NWNX_ON_DM_SET_STAT_AFTER + - NWNX_ON_DM_GET_VARIABLE_BEFORE + - NWNX_ON_DM_GET_VARIABLE_AFTER + - NWNX_ON_DM_SET_VARIABLE_BEFORE + - NWNX_ON_DM_SET_VARIABLE_AFTER + - NWNX_ON_DM_SET_TIME_BEFORE + - NWNX_ON_DM_SET_TIME_AFTER + - NWNX_ON_DM_SET_DATE_BEFORE + - NWNX_ON_DM_SET_DATE_AFTER + - NWNX_ON_DM_SET_FACTION_REPUTATION_BEFORE + - NWNX_ON_DM_SET_FACTION_REPUTATION_AFTER + - NWNX_ON_DM_GET_FACTION_REPUTATION_BEFORE + - NWNX_ON_DM_GET_FACTION_REPUTATION_AFTER + + `OBJECT_SELF` = The DM + +_______________________________________ + ## Client Disconnect Events + - NWNX_ON_CLIENT_DISCONNECT_BEFORE + - NWNX_ON_CLIENT_DISCONNECT_AFTER + + `OBJECT_SELF` = The player disconnecting from the server + + @note This event also runs when a player connects to the server but cancels out of character select. + OBJECT_SELF will be OBJECT_INVALID in this case. + +_______________________________________ + ## Client Connect Events + - NWNX_ON_CLIENT_CONNECT_BEFORE + - NWNX_ON_CLIENT_CONNECT_AFTER + + `OBJECT_SELF` = The module + + Event Data Tag | Type | Notes + ----------------------|--------|------- + PLAYER_NAME | string | Player name of the connecting client + CDKEY | string | Public cdkey of the connecting client + IS_DM | int | Whether the client is connect as DM (1/0) + IP_ADDRESS | string | The IP address of the connecting client + + @note Skipping the _BEFORE event will cause the client's connection to be denied. + You can optionally pass a reason for this in the event result. + +_______________________________________ + ## CombatEnter/Exit Events + - NWNX_ON_COMBAT_ENTER_BEFORE + - NWNX_ON_COMBAT_ENTER_AFTER + - NWNX_ON_COMBAT_EXIT_BEFORE + - NWNX_ON_COMBAT_EXIT_AFTER + + `OBJECT_SELF` = The player entering/exiting combat. + + @note Only works for PCs. + +_______________________________________ + ## Combat Round Start Events + - NWNX_ON_START_COMBAT_ROUND_BEFORE + - NWNX_ON_START_COMBAT_ROUND_AFTER + + `OBJECT_SELF` = The creature starting the combat round + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET_OBJECT_ID | object | Convert to object with StringToObject() + +_______________________________________ + ## Disarm Events + - NWNX_ON_DISARM_BEFORE + - NWNX_ON_DISARM_AFTER + + `OBJECT_SELF` = The creature who is being disarmed + + Event Data Tag | Type | Notes + ----------------------|--------|------- + DISARMER_OBJECT_ID | object | The object disarming the creature + FEAT_ID | int | The feat used to perform the disarming (Normal vs Improved Disarm) + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events + +_______________________________________ + ## Cast Spell Events + - NWNX_ON_CAST_SPELL_BEFORE + - NWNX_ON_CAST_SPELL_AFTER + + `OBJECT_SELF` = The creature casting the spell + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SPELL_ID | int | | + TARGET_POSITION_X | float | | + TARGET_POSITION_Y | float | | + TARGET_POSITION_Z | float | | + TARGET_OBJECT_ID | object | Convert to object with StringToObject() | + ITEM_OBJECT_ID | object | Convert to object with StringToObject() | + MULTI_CLASS | int | | + SPELL_COUNTERED | int | Returns TRUE if spell was countered else FALSE | + COUNTERING_SPELL | int | Returns TRUE if cast as counter else FALSE | + PROJECTILE_PATH_TYPE | int | | + IS_INSTANT_SPELL | int | Returns TRUE if spell was instant else FALSE | + +@note the stock nwscript GetMetaMagicFeat() function will return any metamagic used. + +_______________________________________ + ## Set Memorized Spell Slot Events + - NWNX_SET_MEMORIZED_SPELL_SLOT_BEFORE + - NWNX_SET_MEMORIZED_SPELL_SLOT_AFTER + + `OBJECT_SELF` = The creature who's memorizing the spell + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SPELL_MULTICLASS | int | Index of the spell casting class (0-2) | + SPELL_SLOT | int | | + SPELL_ID | int | | + SPELL_DOMAIN | int | | + SPELL_METAMAGIC | int | | + SPELL_FROMCLIENT | int | | + ACTION_RESULT | int | | + +_______________________________________ + ## Clear Memorized Spell Slot Events + - NWNX_CLEAR_MEMORIZED_SPELL_SLOT_BEFORE + - NWNX_CLEAR_MEMORIZED_SPELL_SLOT_AFTER + + `OBJECT_SELF` = The creature whose spellbook is being changed + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SPELL_MULTICLASS | int | Index of the spell casting class (0-2) | + SPELL_LEVEL | int | | + SPELL_SLOT | int | | + +_______________________________________ + ## Spell Interrupted Events + - NWNX_ON_SPELL_INTERRUPTED_BEFORE + - NWNX_ON_SPELL_INTERRUPTED_AFTER + + `OBJECT_SELF` = The creature whose spell was interrupted + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SPELL_ID | int | | + SPELL_CLASS | int | Index of the spell casting class (0-2) | + SPELL_DOMAIN | int | | + SPELL_METAMAGIC | int | | + SPELL_FEAT | int | | + SPELL_SPONTANEOUS | int | | + +_______________________________________ + ## Healer Kit Use Events + - NWNX_ON_HEALER_KIT_BEFORE + - NWNX_ON_HEALER_KIT_AFTER + + `OBJECT_SELF` = The creature using the Healer's Kit + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + TARGET_OBJECT_ID | object | Convert to object with StringToObject() | + ITEM_OBJECT_ID | object | Convert to object with StringToObject() | + ITEM_PROPERTY_INDEX | int | | + MOVE_TO_TARGET | int | | + ACTION_RESULT | int | | + +_______________________________________ + ## Healing Events + - NWNX_ON_HEAL_BEFORE + - NWNX_ON_HEAL_AFTER + + `OBJECT_SELF` = The creature performing the heal + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + TARGET_OBJECT_ID | object | Convert to object with StringToObject() | + HEAL_AMOUNT | int | How many HP the heal will provide | + +_______________________________________ + ## Party Action Events + - NWNX_ON_PARTY_*_BEFORE + - NWNX_ON_PARTY_*_AFTER + + `OBJECT_SELF` = The player doing the action + + Replace * with an event listed below + + Event | Event Data Tag | Type | Notes | + ----------------|-----------------------|--------|-------| + LEAVE | LEAVING | object | Convert to object with StringToObject() | + KICK | KICKED | object | Convert to object with StringToObject() | + TRANSFER_LEADERSHIP | NEW_LEADER | object | Convert to object with StringToObject() | + INVITE | INVITED | object | Convert to object with StringToObject() | + IGNORE_INVITATION | INVITED_BY | object | Convert to object with StringToObject() | + ACCEPT_INVITATION | INVITED_BY | object | Convert to object with StringToObject() | + REJECT_INVITATION | INVITED_BY | object | Convert to object with StringToObject() | + KICK_HENCHMAN | INVITED_BY | object | Convert to object with StringToObject() | + +_______________________________________ + ## Combat Mode Toggle Events + - NWNX_ON_COMBAT_MODE_ON + - NWNX_ON_COMBAT_MODE_OFF + + `OBJECT_SELF` = The Player Character toggling the mode + + Event Data Tag | Type | Notes + ----------------------|--------|------- + COMBAT_MODE_ID | int | See below + + The `COMBAT_MODE_ID` returned does not match the `COMBAT_MODE_*` NWScript constants. Use the following: + Combat Mode | ID + ----------------------|---- + NONE | 0 + PARRY | 1 + POWER_ATTACK | 2 + IMPROVED_POWER_ATTACK | 3 + COUNTERSPELL | 4 + FLURRY_OF_BLOWS | 5 + RAPID_SHOT | 6 + EXPERTISE | 7 + IMPROVED_EXPERTISE | 8 + DEFENSIVE_CASTING | 9 + DIRTY_FIGHTING | 10 + DEFENSIVE_STANCE | 11 + + @note Requires @ref combatmodes "NWNX_CombatModes" plugin to work. + +_______________________________________ + ## Use Skill Events + - NWNX_ON_USE_SKILL_BEFORE + - NWNX_ON_USE_SKILL_AFTER + + `OBJECT_SELF` = The creature using the skill + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + USED_ITEM_OBJECT_ID | object | Convert to object with StringToObject() | + TARGET_OBJECT_ID | object | Convert to object with StringToObject() | + SKILL_ID | int | | + SUB_SKILL_ID | int | | + TARGET_POSITION_X | float | | + TARGET_POSITION_Y | float | | + TARGET_POSITION_Z | float | | + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events + + @note Probably only really works with the following activated skills: + `SKILL_ANIMAL_EMPATHY`, `SKILL_DISABLE_TRAP`, `SKILL_HEAL`, `SKILL_OPEN_LOCK`, + `SKILL_PICK_POCKET`, `SKILL_TAUNT` + +_______________________________________ + ## Map Pin Events + - NWNX_ON_MAP_PIN_ADD_PIN_BEFORE + - NWNX_ON_MAP_PIN_ADD_PIN_AFTER + - NWNX_ON_MAP_PIN_CHANGE_PIN_BEFORE + - NWNX_ON_MAP_PIN_CHANGE_PIN_AFTER + - NWNX_ON_MAP_PIN_DESTROY_PIN_BEFORE + - NWNX_ON_MAP_PIN_DESTROY_PIN_AFTER + + `OBJECT_SELF` = The player performing the map pin action + + Event Data Tag | Type | Notes + ----------------------|--------|------- + PIN_X | float | Not available in DESTROY event + PIN_Y | float | Not available in DESTROY event + PIN_ID | int | Not available in ADD events. Use `GetLocalInt(oPC, "NW_TOTAL_MAP_PINS")` + PIN_NOTE | string | Not available in DESTROY event + +_______________________________________ + ## Spot/Listen Detection Events + - NWNX_ON_DO_LISTEN_DETECTION_BEFORE + - NWNX_ON_DO_LISTEN_DETECTION_AFTER + - NWNX_ON_DO_SPOT_DETECTION_BEFORE + - NWNX_ON_DO_SPOT_DETECTION_AFTER + + `OBJECT_SELF` = The creature doing the detecting + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + TARGET_INVISIBLE | int | TRUE/FALSE + BEFORE_RESULT | int | TRUE/FALSE, only in _AFTER events + +_______________________________________ + ## Polymorph Events + - NWNX_ON_POLYMORPH_BEFORE + - NWNX_ON_POLYMORPH_AFTER + - NWNX_ON_UNPOLYMORPH_BEFORE + - NWNX_ON_UNPOLYMORPH_AFTER + + `OBJECT_SELF` = The creature doing the un/polymorphing + + Event Data Tag | Type | Notes + ----------------------|--------|------- + POLYMORPH_TYPE | int | Appearance polymorphing into. Only for ON_POLYMORPH + + @warning If skipping the ON_POLYMORPH event, in some cases bioware scripts will enter an endless loop + trying to merge item properties.\n + This can be seen in `x2_s2_gwildshp` with the minotaur form with the following line: + `IPWildShapeCopyItemProperties(oWeaponOld,oWeaponNew, TRUE);` + If you want to skip this, you need to make sure oWeaponOld != oWeaponNew + +_______________________________________ + ## Effect Applied/Removed Events + - NWNX_ON_EFFECT_APPLIED_BEFORE + - NWNX_ON_EFFECT_APPLIED_AFTER + - NWNX_ON_EFFECT_REMOVED_BEFORE + - NWNX_ON_EFFECT_REMOVED_AFTER + + `OBJECT_SELF` = The target of the effect + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + UNIQUE_ID | int | | + CREATOR | object | Convert to object with StringToObject() | + TYPE | int | The effect type, does not match NWScript constants See: https://github.com/nwnxee/unified/blob/master/NWNXLib/API/Constants/Effect.hpp#L8 | + SUB_TYPE | int | SUBTYPE_* | + DURATION_TYPE | int | DURATION_TYPE_* | + DURATION | float | | + SPELL_ID | int | | + CASTER_LEVEL | int | | + CUSTOM_TAG | string | | + INT_PARAM_* | int | * = 1-8 | + FLOAT_PARAM_* | float | * = 1-4 | + STRING_PARAM_* | string | * = 1-6 | + OBJECT_PARAM_* | object | * = 1-4, Convert to object with StringToObject() | + + @note Only fires for Temporary or Permanent effects, does not include VisualEffects or ItemProperty effects. + +_______________________________________ + ## Quickchat Events + - NWNX_ON_QUICKCHAT_BEFORE + - NWNX_ON_QUICKCHAT_AFTER + + `OBJECT_SELF` = The player using the quick chat command + + Event Data Tag | Type | Notes + ----------------------|--------|------- + QUICKCHAT_COMMAND | int | `VOICE_CHAT_*` constants + +_______________________________________ + ## Inventory Open Events + - NWNX_ON_INVENTORY_OPEN_BEFORE + - NWNX_ON_INVENTORY_OPEN_AFTER + + `OBJECT_SELF` = The player opening the inventory + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET_INVENTORY | object | Pretty sure this is always the player + +_______________________________________ + ## Inventory Select Panel Events + - NWNX_ON_INVENTORY_SELECT_PANEL_BEFORE + - NWNX_ON_INVENTORY_SELECT_PANEL_AFTER + + `OBJECT_SELF` = The player changing inventory panels + + Event Data Tag | Type | Notes + ----------------------|--------|------- + CURRENT_PANEL | int | The current panel, index starts at 0 + SELECTED_PANEL | int | The selected panel, index starts at 0 + +_______________________________________ + ## Barter Start Events + - NWNX_ON_BARTER_START_BEFORE + - NWNX_ON_BARTER_START_AFTER + + `OBJECT_SELF` = The player who initiated the barter + + Event Data Tag | Type | Notes + ----------------------|--------|------- + BARTER_TARGET | object | The other player involved in the barter + +_______________________________________ + ## Barter End Events + - NWNX_ON_BARTER_END_BEFORE + - NWNX_ON_BARTER_END_AFTER + + `OBJECT_SELF` = The player who initiated the barter + + Event Data Tag | Type | Notes + ------------------------------|--------|------- + BARTER_TARGET | object | The other player involved in the barter + BARTER_COMPLETE | int | TRUE/FALSE - whether the barter completed successfully + BARTER_INITIATOR_ITEM_COUNT | int | How many items the initiator traded away, only in _BEFORE events + BARTER_TARGET_ITEM_COUNT | int | How many items the target traded away, only in _BEFORE events + BARTER_INITIATOR_ITEM_* | object | Convert to object with StringToObject(), only in _BEFORE events + BARTER_TARGET_ITEM_* | object | Convert to object with StringToObject(), only in _BEFORE events + +_______________________________________ + ## Trap Events + - NWNX_ON_TRAP_DISARM_BEFORE + - NWNX_ON_TRAP_DISARM_AFTER + - NWNX_ON_TRAP_ENTER_BEFORE + - NWNX_ON_TRAP_ENTER_AFTER + - NWNX_ON_TRAP_EXAMINE_BEFORE + - NWNX_ON_TRAP_EXAMINE_AFTER + - NWNX_ON_TRAP_FLAG_BEFORE + - NWNX_ON_TRAP_FLAG_AFTER + - NWNX_ON_TRAP_RECOVER_BEFORE + - NWNX_ON_TRAP_RECOVER_AFTER + - NWNX_ON_TRAP_SET_BEFORE + - NWNX_ON_TRAP_SET_AFTER + + `OBJECT_SELF` = The creature performing the trap action + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TRAP_OBJECT_ID | object | Convert to object with StringToObject() + TRAP_FORCE_SET | int | TRUE/FALSE, only in ENTER events + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events (not ENTER) + +_______________________________________ + ## Timing Bar Events + - NWNX_ON_TIMING_BAR_START_BEFORE + - NWNX_ON_TIMING_BAR_START_AFTER + - NWNX_ON_TIMING_BAR_STOP_BEFORE + - NWNX_ON_TIMING_BAR_STOP_AFTER + - NWNX_ON_TIMING_BAR_CANCEL_BEFORE + - NWNX_ON_TIMING_BAR_CANCEL_AFTER + + `OBJECT_SELF` = The player the timing bar is for + + Event Data Tag | Type | Notes + ----------------------|--------|------- + EVENT_ID | int | The type of timing bar, see constants below, only in _START_ events + DURATION | int | Length of time (in milliseconds) the bar is set to last, only in _START_ events + +_______________________________________ + ## Webhook Events + - NWNX_ON_WEBHOOK_SUCCESS + - NWNX_ON_WEBHOOK_FAILURE + + `OBJECT_SELF` = The module object + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + STATUS | int | The return code after posting to the server | + MESSAGE | string | The full constructed message sent | + HOST | string | | + PATH | string | | + RATELIMIT_LIMIT | int | Discord: The number of requests that can be made in a limited period | + RATELIMIT_REMAINING | int | Discord: The number of remaining requests that can be made before rate limited | + RATELIMIT_RESET | int | Discord: Timestamp when the rate limit resets | + RETRY_AFTER | float | Milliseconds until another webhook is allowed when rate limited | + FAIL_INFO | string | The reason the hook failed aside from rate limits | + + @note Requires @ref webhook "NWNX_WebHook" plugin to work. + +_______________________________________ + ## Servervault Events + - NWNX_ON_CHECK_STICKY_PLAYER_NAME_RESERVED_BEFORE + - NWNX_ON_CHECK_STICKY_PLAYER_NAME_RESERVED_AFTER + + `OBJECT_SELF` = The module + + Event Data Tag | Type | Notes + ----------------------|--------|------- + PLAYER_NAME | string | Player name of the connecting client + CDKEY | string | Public cdkey of the connecting client + LEGACY_CDKEY | string | Public cdkey from earlier versions of NWN + IS_DM | int | Whether the client is connecting as DM (1/0) + + @note Skipping the _BEFORE event will cause no player names to be accepted unless you SetEventResult("1") + +_______________________________________ + ## Server Character Save Events + - NWNX_ON_SERVER_CHARACTER_SAVE_BEFORE + - NWNX_ON_SERVER_CHARACTER_SAVE_AFTER + + `OBJECT_SELF` = The player character being saved. + + @note This is called once for every character when the server is exiting and when the server is saved, or when ExportSingleCharacter() & ExportAllCharacters() is called. + +_______________________________________ + ## Export Character Events + - NWNX_ON_CLIENT_EXPORT_CHARACTER_BEFORE + - NWNX_ON_CLIENT_EXPORT_CHARACTER_AFTER + + `OBJECT_SELF` = The player + + Note: This event runs when the player clicks the "Save Character" button in the options menu to export their character to their localvault. + +_______________________________________ + ## Levelling Events + - NWNX_ON_LEVEL_UP_BEFORE + - NWNX_ON_LEVEL_UP_AFTER + - NWNX_ON_LEVEL_UP_AUTOMATIC_BEFORE + - NWNX_ON_LEVEL_UP_AUTOMATIC_AFTER + - NWNX_ON_LEVEL_DOWN_BEFORE + - NWNX_ON_LEVEL_DOWN_AFTER + + `OBJECT_SELF` = The creature levelling up or down, automatic is for henchmen levelling + +_______________________________________ + ## Container Change Events + - NWNX_ON_INVENTORY_ADD_ITEM_BEFORE + - NWNX_ON_INVENTORY_ADD_ITEM_AFTER + - NWNX_ON_INVENTORY_REMOVE_ITEM_BEFORE + - NWNX_ON_INVENTORY_REMOVE_ITEM_AFTER + + @note NWNX_ON_INVENTORY_REMOVE_ITEM_* is not skippable + + `OBJECT_SELF` = The container + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ITEM | object | Convert to object with StringToObject() + +_______________________________________ + ## Gold Events + - NWNX_ON_INVENTORY_ADD_GOLD_BEFORE + - NWNX_ON_INVENTORY_ADD_GOLD_AFTER + - NWNX_ON_INVENTORY_REMOVE_GOLD_BEFORE + - NWNX_ON_INVENTORY_REMOVE_GOLD_AFTER + + `OBJECT_SELF` = The creature gaining or losing gold + + Event Data Tag | Type | Notes + ----------------------|--------|------- + GOLD | int | The amount of gold added or removed + + @warning While these events are skippable, you should be very careful about doing so. + It's very easy to create situations where players can dupe their gold or worse. + +_______________________________________ + ## PVP Attitude Change Events + - NWNX_ON_PVP_ATTITUDE_CHANGE_BEFORE + - NWNX_ON_PVP_ATTITUDE_CHANGE_AFTER + + `OBJECT_SELF` = The player performing the attitude change + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET_OBJECT_ID | object | Convert to object with StringToObject() + ATTITUDE | int | 0 = Dislike, 1 = Like + +_______________________________________ + ## Input Walk To Events + - NWNX_ON_INPUT_WALK_TO_WAYPOINT_BEFORE + - NWNX_ON_INPUT_WALK_TO_WAYPOINT_AFTER + + `OBJECT_SELF` = The player clicking somewhere to move + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + AREA | object | Convert to object with StringToObject() | + POS_X | float | | + POS_Y | float | | + POS_Z | float | | + RUN_TO_POINT | int | TRUE if player is running, FALSE if player is walking (eg when shift clicking) | + +_______________________________________ + ## Material Change Events + - NWNX_ON_MATERIALCHANGE_BEFORE + - NWNX_ON_MATERIALCHANGE_AFTER + + `OBJECT_SELF` = The creature walking on a different surface material + + Event Data Tag | Type | Notes + ----------------------|--------|------- + MATERIAL_TYPE | int | See surfacemat.2da for values + + @note: After a PC transitions to a new area, a surface material change event + won't fire until after the PC moves. + +_______________________________________ + ## Input Attack Events + - NWNX_ON_INPUT_ATTACK_OBJECT_BEFORE + - NWNX_ON_INPUT_ATTACK_OBJECT_AFTER + + `OBJECT_SELF` = The creature attacking + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + PASSIVE | int | TRUE / FALSE + CLEAR_ALL_ACTIONS | int | TRUE / FALSE + ADD_TO_FRONT | int | TRUE / FALSE + +_______________________________________ + ## Input Force Move To Events + - NWNX_ON_INPUT_FORCE_MOVE_TO_OBJECT_BEFORE + - NWNX_ON_INPUT_FORCE_MOVE_TO_OBJECT_AFTER + + `OBJECT_SELF` = The creature forcibly moving + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + + _______________________________________ + ## Input Cast Spell Events + - NWNX_ON_INPUT_CAST_SPELL_BEFORE + - NWNX_ON_INPUT_CAST_SPELL_AFTER + + `OBJECT_SELF` = The creature casting a spell + + Event Data Tag | Type | Notes + ----------------------|--------|------- + TARGET | object | Convert to object with StringToObject() + SPELL_ID | int | + MULTICLASS | int | + DOMAIN_LEVEL | int | + META_TYPE | int | + INSTANT | int | TRUE / FALSE + PROJECTILE_PATH | int | + SPONTANEOUS | int | TRUE / FALSE + FAKE | int | TRUE / FALSE + FEAT | int | -1 when not cast from a feat + CASTER_LEVEL | int | + IS_AREA_TARGET | int | TRUE / FALSE + POS_X | float | + POS_Y | float | + POS_Z | float | + + @note This event runs the moment a creature starts casting + +_______________________________________ + ## Input Keyboard Events + - NWNX_ON_INPUT_KEYBOARD_BEFORE + - NWNX_ON_INPUT_KEYBOARD_AFTER + + `OBJECT_SELF` = The player + + Event Data Tag | Type | Notes + ----------------------|--------|------- + KEY | string | The key pressed by the player, one of the following: W A S D Q E + + @note To stop the player from moving you can do something like below, since normal immobilizing effects stop the client + from sending input. + + location locPlayer = GetLocation(oPlayer); + object oBoulder = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_boulder", locPlayer, FALSE, "TESTPLC"); + NWNX_Object_SetPosition(oPlayer, GetPositionFromLocation(locPlayer)); + ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY), oBoulder); + +_______________________________________ + ## Input Keyboard Events + - NWNX_ON_INPUT_TOGGLE_PAUSE_BEFORE + - NWNX_ON_INPUT_TOGGLE_PAUSE_AFTER + + `OBJECT_SELF` = The player or DM + + Event Data Tag | Type | Notes + ----------------------|--------|------- + PAUSE_STATE | int | TRUE = Pausing, FALSE = Unpausing + + @note This event also fires when a non-dm player presses the spacebar. + +_______________________________________ + ## Object Lock Events + - NWNX_ON_OBJECT_LOCK_BEFORE + - NWNX_ON_OBJECT_LOCK_AFTER + + `OBJECT_SELF` = The object doing the locking + + Event Data Tag | Type | Notes + ----------------------|--------|------- + DOOR | object | Convert to object with StringToObject() + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events + +_______________________________________ + ## Object Unlock Events + - NWNX_ON_OBJECT_UNLOCK_BEFORE + - NWNX_ON_OBJECT_UNLOCK_AFTER + + `OBJECT_SELF` = The object doing the unlocking + + Event Data Tag | Type | Notes + ----------------------|--------|------- + DOOR | object | Convert to object with StringToObject() + THIEVES_TOOL | object | Convert to object with StringToObject() + ACTIVE_PROPERTY_INDEX | int | + ACTION_RESULT | int | TRUE/FALSE, only in _AFTER events + +_______________________________________ + ## UUID Collision Events + - NWNX_ON_UUID_COLLISION_BEFORE + - NWNX_ON_UUID_COLLISION_AFTER + + `OBJECT_SELF` = The object that caused the UUID collision + + Event Data Tag | Type | Notes + ----------------------|--------|------- + UUID | string | The UUID + + Note: To get the existing object with `UUID` you can use GetObjectByUUID(), be aware that this event runs before the + object is added to the world which means many functions (for example `GetArea(OBJECT_SELF)`) will not work. + +_______________________________________ + ## Resource Events + - NWNX_ON_RESOURCE_ADDED + - NWNX_ON_RESOURCE_REMOVED + - NWNX_ON_RESOURCE_MODIFIED + + `OBJECT_SELF` = The module + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ALIAS | string | NWNX for /nwnx, DEVELOPMENT for /development. Also supports valid aliases from the Custom Resman Definition File + RESREF | string | The ResRef of the file + TYPE | int | The type of the file, see NWNX_UTIL_RESREF_TYPE_* + + Note: These events fire when a file gets added/removed/modified in resource folders like /nwnx, /development and those defined in the Custom Resman Definition File + +_______________________________________ + ## ELC Events + - NWNX_ON_ELC_VALIDATE_CHARACTER_BEFORE + - NWNX_ON_ELC_VALIDATE_CHARACTER_AFTER + + `OBJECT_SELF` = The player + + Note: NWNX_ELC must be loaded for these events to work. The `_AFTER` event only fires if the character successfully + completes validation. + +_______________________________________ + ## Quickbar Events + - NWNX_ON_QUICKBAR_SET_BUTTON_BEFORE + - NWNX_ON_QUICKBAR_SET_BUTTON_AFTER + + `OBJECT_SELF` = The player + + Event Data Tag | Type | Notes + ----------------------|--------|------- + BUTTON | int | The quickbar button slot, 0-35 + TYPE | int | The type of quickbar button set, see NWNX_PLAYER_QBS_TYPE_* in nwnx_player_qbs.nss + + Note: Skipping the event does not prevent the client from changing the button clientside, the change won't however + be saved to the bic file. + +_______________________________________ + ## Calendar Events + - NWNX_ON_CALENDAR_HOUR + - NWNX_ON_CALENDAR_DAY + - NWNX_ON_CALENDAR_MONTH + - NWNX_ON_CALENDAR_YEAR + - NWNX_ON_CALENDAR_DAWN + - NWNX_ON_CALENDAR_DUSK + + `OBJECT_SELF` = The module + + Event Data Tag | Type | Notes + ----------------------|--------|------- + OLD | int | The (Hour/Day/Month/Year) before the change. Not available in DAWN/DUSK. + NEW | int | The (Hour/Day/Month/Year) after the change. Not available in DAWN/DUSK. + +_______________________________________ + ## Broadcast Spell Cast Events + - NWNX_ON_BROADCAST_CAST_SPELL_BEFORE + - NWNX_ON_BROADCAST_CAST_SPELL_AFTER + + `OBJECT_SELF` = The creature casting the spell + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SPELL_ID | int | | + MULTI_CLASS | int | | + FEAT | int | 65535 if a feat wasn't used, otherwise the feat ID | + +_______________________________________ + ## RunScript Debug Event + - NWNX_ON_DEBUG_RUN_SCRIPT_BEFORE + - NWNX_ON_DEBUG_RUN_SCRIPT_AFTER + + `OBJECT_SELF` = The player executing the RunScript debug command + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SCRIPT_NAME | string | The script to execute | + TARGET | object | The target to run the script on. Convert to object with StringToObject() | + + @note This event also runs for players that do not have permission to execute the command. + +_______________________________________ + ## RunScriptChunk Debug Event + - NWNX_ON_DEBUG_RUN_SCRIPT_CHUNK_BEFORE + - NWNX_ON_DEBUG_RUN_SCRIPT_CHUNK_AFTER + + `OBJECT_SELF` = The player executing the RunScriptChunk debug command + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + SCRIPT_CHUNK | string | The script chunk | + TARGET | object | The target to run the script chunk on. Convert to object with StringToObject() | + WRAP_INTO_MAIN | int | TRUE if the WrapIntoMain checkbox is checked, otherwise FALSE | + + @note This event also runs for players that do not have permission to execute the command. + +_______________________________________ + ## Buy/Sell Store Events + - NWNX_ON_STORE_REQUEST_BUY_BEFORE + - NWNX_ON_STORE_REQUEST_BUY_AFTER + - NWNX_ON_STORE_REQUEST_SELL_BEFORE + - NWNX_ON_STORE_REQUEST_SELL_AFTER + + `OBJECT_SELF` = The creature buying or selling an item + + Event Data Tag | Type | Notes | + ----------------------|--------|-------| + ITEM | object | The item being bought or sold. Convert to object with StringToObject() | + STORE | object | The store the item is being sold to or bought from. Convert to object with StringToObject() | + PRICE | int | The buy or sell price | + RESULT | int | TRUE/FALSE whether the request was successful. Only in *_AFTER events. + +_______________________________________ + ## Server Send Area Events + - NWNX_ON_SERVER_SEND_AREA_BEFORE + - NWNX_ON_SERVER_SEND_AREA_AFTER + + `OBJECT_SELF` = The player + + Event Data Tag | Type | Notes + ----------------------|--------|------- + AREA | object | The area the server is sending. Convert to object with StringToObject() | + PLAYER_NEW_TO_MODULE | int | TRUE if it's the player's first time logging into the server since a restart | + +_______________________________________ + ## Journal Open/Close Events + - NWNX_ON_JOURNAL_OPEN_BEFORE + - NWNX_ON_JOURNAL_OPEN_AFTER + - NWNX_ON_JOURNAL_CLOSE_BEFORE + - NWNX_ON_JOURNAL_CLOSE_AFTER + + `OBJECT_SELF` = The player + + Event Data Tag | Type | Notes + ----------------------|--------|------- + +_______________________________________ + ## Input Emote Event + - NWNX_ON_INPUT_EMOTE_BEFORE + - NWNX_ON_INPUT_EMOTE_AFTER + + `OBJECT_SELF` = The creature using a radial menu emote + + Event Data Tag | Type | Notes + ----------------------|--------|------- + ANIMATION | int | An engine animation constant, convent to NWScript animation constant with NWNX_Consts_TranslateEngineAnimation() | + + @note Some emotes have a voiceline that will still play when the event is skipped. These voicelines can be skipped in the NWNX_ON_QUICKCHAT_* event. + +_______________________________________ +*/ +/* +const int NWNX_EVENTS_OBJECT_TYPE_CREATURE = 5; +const int NWNX_EVENTS_OBJECT_TYPE_ITEM = 6; +const int NWNX_EVENTS_OBJECT_TYPE_TRIGGER = 7; +const int NWNX_EVENTS_OBJECT_TYPE_PLACEABLE = 9; +const int NWNX_EVENTS_OBJECT_TYPE_WAYPOINT = 12; +const int NWNX_EVENTS_OBJECT_TYPE_ENCOUNTER = 13; +const int NWNX_EVENTS_OBJECT_TYPE_PORTAL = 15; +*/ + +/* +const int NWNX_EVENTS_TIMING_BAR_TRAP_FLAG = 1; +const int NWNX_EVENTS_TIMING_BAR_TRAP_RECOVER = 2; +const int NWNX_EVENTS_TIMING_BAR_TRAP_DISARM = 3; +const int NWNX_EVENTS_TIMING_BAR_TRAP_EXAMINE = 4; +const int NWNX_EVENTS_TIMING_BAR_TRAP_SET = 5; +const int NWNX_EVENTS_TIMING_BAR_REST = 6; +const int NWNX_EVENTS_TIMING_BAR_UNLOCK = 7; +const int NWNX_EVENTS_TIMING_BAR_LOCK = 8; +const int NWNX_EVENTS_TIMING_BAR_CUSTOM = 10; +*/ + +/// @brief Scripts can subscribe to events. +/// +/// Some events are dispatched via the NWNX plugin (see NWNX_EVENTS_EVENT_* constants). +/// Others can be signalled via script code via NWNX_Events_SignalEvent(). +/// @param evt The event name. +/// @param script The script to call when the event fires. +void NWNX_Events_SubscribeEvent(string evt, string script); + +/// @brief Unsubscribe a script from an event +/// @param evt The event name. +/// @param script The script. +void NWNX_Events_UnsubscribeEvent(string evt, string script); + +/// Pushes event data at the provided tag, which subscribers can access with GetEventData. +/// This should be called BEFORE SignalEvent. +void NWNX_Events_PushEventData(string tag, string data); + +/// Signals an event. This will dispatch a notification to all subscribed handlers. +/// Returns TRUE if anyone was subscribed to the event, FALSE otherwise. +/// @remark target will be available as OBJECT_SELF in subscribed event scripts. +int NWNX_Events_SignalEvent(string evt, object target); + +/// Retrieves the event data for the currently executing script. +/// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER. +string NWNX_Events_GetEventData(string tag); + +/// Skips execution of the currently executing event. +/// If this is a NWNX event, that means that the base function call won't be called. +/// This won't impact any other subscribers, nor dispatch for before / after functions. +/// For example, if you are subscribing to NWNX_ON_EXAMINE_OBJECT_BEFORE, and you skip ... +/// - The other subscribers will still be called. +/// - The original function in the base game will be skipped. +/// - The matching after event (NWNX_ON_EXAMINE_OBJECT_AFTER) will also be executed. +/// +/// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER. +/// ONLY WORKS WITH THE FOLLOWING EVENTS: +/// - Feat events +/// - Item events +/// - Healing events +/// - CombatMode events +/// - Party events +/// - Skill events +/// - Map events +/// - Listen/Spot Detection events +/// - Polymorph events +/// - DMAction events +/// - Client connect event +/// - Client Export Character event +/// - Spell events +/// - QuickChat events +/// - Barter event (START only) +/// - Trap events +/// - Sticky Player Name event +/// - Server Character Save Events +/// - Add/RemoveGold events +/// - PVP Attitude Change events +/// - {Enter|Exit}Stealth events +/// - Object {Lock|Unlock} events +/// - Quickbar Events +/// - Input Pause Event +/// - Input Emote Event +/// - Debug events +/// - Store events +/// - Disarm event +/// - {Enter|Exit}Detect events +/// - Faction events +void NWNX_Events_SkipEvent(); + +/// Set the return value of the event. +/// +/// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER. +/// ONLY WORKS WITH THE FOLLOWING EVENTS: +/// - Use Item event - "1" or "0" to send feedback whether item use is allowed +/// - Validate Use Item Event - "1" or "0" to show the item is unusable (red) in the player inventory. +/// - Healer's Kit event +/// - Listen/Spot Detection events -> "1" or "0" +/// - OnClientConnectBefore -> Reason for disconnect if skipped +/// - Ammo Reload event -> Forced ammunition returned +/// - Trap events -> "1" or "0" +/// - Sticky Player Name event -> "1" or "0" +/// - Heal event -> Amount of HP to heal +/// - Has Feat event -> "1" or "0" +/// - Stealth event -> "1" to perform HiPS (without the feat), "0" to bypass HiPS +/// - Faction set reputation event -> The new reputation to apply instead. ("0" - "100") +void NWNX_Events_SetEventResult(string data); + +/// Returns the current event name +/// +/// Returns "" on error +string NWNX_Events_GetCurrentEvent(); + +/// Toggles DispatchListMode for sEvent+sScript +/// If enabled, sEvent for sScript will only be signalled if the target object is on its dispatch list. +void NWNX_Events_ToggleDispatchListMode(string sEvent, string sScript, int bEnable); + +/// Add oObject to the dispatch list for sEvent+sScript. +void NWNX_Events_AddObjectToDispatchList(string sEvent, string sScript, object oObject); + +/// Remove oObject from the dispatch list for sEvent+sScript. +void NWNX_Events_RemoveObjectFromDispatchList(string sEvent, string sScript, object oObject); + +/// @brief Toggle the whitelisting of IDs for sEvent. If whitelisting is enabled, the event will only fire for IDs that are +/// on its whitelist. +/// +/// ONLY WORKS WITH THE FOLLOWING EVENTS -> ID TYPES: +/// - NWNX_ON_CAST_SPELL -> SpellID +/// - NWNX_ON_HAS_FEAT -> FeatID (default enabled) +/// +/// @note This enables the whitelist for ALL scripts subscribed to sEvent. +/// @param sEvent The event name without _BEFORE / _AFTER. +/// @param bEnable TRUE to enable the whitelist, FALSE to disable +void NWNX_Events_ToggleIDWhitelist(string sEvent, int bEnable); + +/// @brief Add nID to the whitelist of sEvent. +/// @note See NWNX_Events_ToggleIDWhitelist for valid events and ID types. +/// @param sEvent The event name without _BEFORE / _AFTER. +/// @param nID The ID. +void NWNX_Events_AddIDToWhitelist(string sEvent, int nID); + +/// @brief Remove nID from the whitelist of sEvent. +/// @note See NWNX_Events_ToggleIDWhitelist for valid events and ID types. +/// @param sEvent The event name without _BEFORE / _AFTER. +/// @param nID The ID. +void NWNX_Events_RemoveIDFromWhitelist(string sEvent, int nID); + +/// @} + +void NWNX_Events_SubscribeEvent(string evt, string script) +{ + string sFunc = "SubscribeEvent"; + + NWNX_PushArgumentString(NWNX_Events, sFunc, script); + NWNX_PushArgumentString(NWNX_Events, sFunc, evt); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_UnsubscribeEvent(string evt, string script) +{ + string sFunc = "UnsubscribeEvent"; + + NWNX_PushArgumentString(NWNX_Events, sFunc, script); + NWNX_PushArgumentString(NWNX_Events, sFunc, evt); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_PushEventData(string tag, string data) +{ + string sFunc = "PushEventData"; + + NWNX_PushArgumentString(NWNX_Events, sFunc, data); + NWNX_PushArgumentString(NWNX_Events, sFunc, tag); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +int NWNX_Events_SignalEvent(string evt, object target) +{ + string sFunc = "SignalEvent"; + + NWNX_PushArgumentObject(NWNX_Events, sFunc, target); + NWNX_PushArgumentString(NWNX_Events, sFunc, evt); + NWNX_CallFunction(NWNX_Events, sFunc); + return NWNX_GetReturnValueInt(NWNX_Events, sFunc); +} + +string NWNX_Events_GetEventData(string tag) +{ + string sFunc = "GetEventData"; + + NWNX_PushArgumentString(NWNX_Events, sFunc, tag); + NWNX_CallFunction(NWNX_Events, sFunc); + return NWNX_GetReturnValueString(NWNX_Events, sFunc); +} + +void NWNX_Events_SkipEvent() +{ + string sFunc = "SkipEvent"; + + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_SetEventResult(string data) +{ + string sFunc = "SetEventResult"; + + NWNX_PushArgumentString(NWNX_Events, sFunc, data); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +string NWNX_Events_GetCurrentEvent() +{ + string sFunc = "GetCurrentEvent"; + + NWNX_CallFunction(NWNX_Events, sFunc); + return NWNX_GetReturnValueString(NWNX_Events, sFunc); +} + +void NWNX_Events_ToggleDispatchListMode(string sEvent, string sScript, int bEnable) +{ + string sFunc = "ToggleDispatchListMode"; + + NWNX_PushArgumentInt(NWNX_Events, sFunc, bEnable); + NWNX_PushArgumentString(NWNX_Events, sFunc, sScript); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_AddObjectToDispatchList(string sEvent, string sScript, object oObject) +{ + string sFunc = "AddObjectToDispatchList"; + + NWNX_PushArgumentObject(NWNX_Events, sFunc, oObject); + NWNX_PushArgumentString(NWNX_Events, sFunc, sScript); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_RemoveObjectFromDispatchList(string sEvent, string sScript, object oObject) +{ + string sFunc = "RemoveObjectFromDispatchList"; + + NWNX_PushArgumentObject(NWNX_Events, sFunc, oObject); + NWNX_PushArgumentString(NWNX_Events, sFunc, sScript); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_ToggleIDWhitelist(string sEvent, int bEnable) +{ + string sFunc = "ToggleIDWhitelist"; + + NWNX_PushArgumentInt(NWNX_Events, sFunc, bEnable); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_AddIDToWhitelist(string sEvent, int nID) +{ + string sFunc = "AddIDToWhitelist"; + + NWNX_PushArgumentInt(NWNX_Events, sFunc, nID); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} + +void NWNX_Events_RemoveIDFromWhitelist(string sEvent, int nID) +{ + string sFunc = "RemoveIDFromWhitelist"; + + NWNX_PushArgumentInt(NWNX_Events, sFunc, nID); + NWNX_PushArgumentString(NWNX_Events, sFunc, sEvent); + NWNX_CallFunction(NWNX_Events, sFunc); +} diff --git a/nwnds_module/nwnx_feat.nss b/nwnds_module/nwnx_feat.nss new file mode 100644 index 000000000..3ee797cec --- /dev/null +++ b/nwnds_module/nwnx_feat.nss @@ -0,0 +1,63 @@ +/// @addtogroup feat Feat +/// @brief Define feat bonuses/penalties +/// @{ +/// @file nwnx_feat.nss +#include "nwnx" + +const string NWNX_Feat = "NWNX_Feat"; ///< @private + +/// @name Feat Modifiers +/// @anchor feat_modifiers +/// +/// @{ +const int NWNX_FEAT_MODIFIER_INVALID = 0; +const int NWNX_FEAT_MODIFIER_AB = 1; +const int NWNX_FEAT_MODIFIER_ABILITY = 2; +const int NWNX_FEAT_MODIFIER_ABVSRACE = 3; +const int NWNX_FEAT_MODIFIER_AC = 4; +const int NWNX_FEAT_MODIFIER_ACVSRACE = 5; +const int NWNX_FEAT_MODIFIER_ARCANESPELLFAILURE = 6; +const int NWNX_FEAT_MODIFIER_CONCEALMENT = 7; +const int NWNX_FEAT_MODIFIER_DMGIMMUNITY = 8; +const int NWNX_FEAT_MODIFIER_DMGREDUCTION = 9; +const int NWNX_FEAT_MODIFIER_DMGRESIST = 10; +const int NWNX_FEAT_MODIFIER_IMMUNITY = 11; +const int NWNX_FEAT_MODIFIER_MOVEMENTSPEED = 12; +const int NWNX_FEAT_MODIFIER_REGENERATION = 13; +const int NWNX_FEAT_MODIFIER_SAVE = 14; +const int NWNX_FEAT_MODIFIER_SAVEVSRACE = 15; +const int NWNX_FEAT_MODIFIER_SAVEVSTYPE = 16; +const int NWNX_FEAT_MODIFIER_SAVEVSTYPERACE = 17; +const int NWNX_FEAT_MODIFIER_SPELLIMMUNITY = 18; +const int NWNX_FEAT_MODIFIER_SRCHARGEN = 19; +const int NWNX_FEAT_MODIFIER_SRINCLEVEL = 20; +const int NWNX_FEAT_MODIFIER_SPELLSAVEDC = 21; +const int NWNX_FEAT_MODIFIER_BONUSSPELL = 22; +const int NWNX_FEAT_MODIFIER_TRUESEEING = 23; +const int NWNX_FEAT_MODIFIER_SEEINVISIBLE = 24; +const int NWNX_FEAT_MODIFIER_ULTRAVISION = 25; +const int NWNX_FEAT_MODIFIER_HASTE = 26; +const int NWNX_FEAT_MODIFIER_VISUALEFFECT = 27; +///@} + +/// @brief Sets a feat modifier. +/// @param iFeat The Feat constant or value in feat.2da. +/// @param iMod The @ref feat_modifiers "feat modifier" to set. +/// @param iParam1, iParam2, iParam3, iParam4 The parameters for this feat modifier. +void NWNX_Feat_SetFeatModifier(int iFeat, int iMod, int iParam1 = 0xDEADBEEF, int iParam2 = 0xDEADBEEF, int iParam3 = 0xDEADBEEF, int iParam4 = 0xDEADBEEF); + +/// @} + +void NWNX_Feat_SetFeatModifier(int iFeat, int iMod, int iParam1 = 0xDEADBEEF, int iParam2 = 0xDEADBEEF, int iParam3 = 0xDEADBEEF, int iParam4 = 0xDEADBEEF) +{ + string sFunc = "SetFeatModifier"; + + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iParam4); + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iParam3); + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iParam2); + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iParam1); + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iMod); + NWNX_PushArgumentInt(NWNX_Feat, sFunc, iFeat); + + NWNX_CallFunction(NWNX_Feat, sFunc); +} diff --git a/nwnds_module/nwnx_feedback.nss b/nwnds_module/nwnx_feedback.nss new file mode 100644 index 000000000..19aa0df9a --- /dev/null +++ b/nwnds_module/nwnx_feedback.nss @@ -0,0 +1,519 @@ +/// @addtogroup feedback Feedback +/// @brief Allows combatlog, feedback and journal updated messages to be hidden globally or per player. +/// @note +/// * If oPC == OBJECT_INVALID it will get/set the global state: +/// * TRUE = Message is globally hidden +/// * FALSE = Message is not globally hidden +/// * If oPC is a valid player it will get/set the personal state: +/// * TRUE = Message is hidden for oPC +/// * FALSE = Message is not hidden for oPC +/// * -1 = Personal state is not set for Message +/// @{ +/// @file nwnx_feedback.nss +#include "nwnx" + +const string NWNX_Feedback = "NWNX_Feedback"; ///< @private + +/// @name Combat Log Message Types +/// @anchor combat_log_msgs +/// @{ +const int NWNX_FEEDBACK_COMBATLOG_SIMPLE_ADJECTIVE = 1; +/* +const int NWNX_FEEDBACK_COMBATLOG_SIMPLE_DAMAGE = 2; +const int NWNX_FEEDBACK_COMBATLOG_COMPLEX_DAMAGE = 3; +const int NWNX_FEEDBACK_COMBATLOG_COMPLEX_DEATH = 4; +const int NWNX_FEEDBACK_COMBATLOG_COMPLEX_ATTACK = 5; +const int NWNX_FEEDBACK_COMBATLOG_SPECIAL_ATTACK = 6; +const int NWNX_FEEDBACK_COMBATLOG_SAVING_THROW = 7; +const int NWNX_FEEDBACK_COMBATLOG_CAST_SPELL = 8; +const int NWNX_FEEDBACK_COMBATLOG_USE_SKILL = 9; +const int NWNX_FEEDBACK_COMBATLOG_SPELL_RESISTANCE = 10; +const int NWNX_FEEDBACK_COMBATLOG_FEEDBACK = 11; // NOTE: This hides ALL feedback messages, to hide individual messages use NWNX_Feedback_SetFeedbackMessageHidden() +const int NWNX_FEEDBACK_COMBATLOG_COUNTERSPELL = 12; +const int NWNX_FEEDBACK_COMBATLOG_TOUCHATTACK = 13; +const int NWNX_FEEDBACK_COMBATLOG_INITIATIVE = 14; +const int NWNX_FEEDBACK_COMBATLOG_DISPEL_MAGIC = 15; +const int NWNX_FEEDBACK_COMBATLOG_POLYMORPH = 17; +const int NWNX_FEEDBACK_COMBATLOG_FEEDBACKSTRING = 18; +const int NWNX_FEEDBACK_COMBATLOG_VIBRATE = 19; +const int NWNX_FEEDBACK_COMBATLOG_UNLOCKACHIEVEMENT = 20; + +// 1 -> Simple_Adjective: : +// 2 -> Simple_Damage: damaged : +// 3 -> Complex_Damage: damages : +// 4 -> Complex_Death: killed +// 5 -> Complex_Attack: attacks : *hit* / *miss* / *parried* : ( + = ) +// 6 -> Special_Attack: attempts on : *success* / *failure* : ( + = ) +// 7 -> Saving_Throw: : : *success* / *failure* : ( + = ) +// 8 -> Cast_Spell: casts : Spellcraft check *failure* / *success* +// 9 -> Use_Skill: : : *success* / *failure* : ( + = vs ) +// 10 -> Spell_Resistance: : Spell Resistance : *success* / *failure* +// 11 -> Feedback: Reason skill/feat/ability failed. +// 12 -> Counterspel: casts : *spell countered by* : casting +// 13 -> TouchAttack: attempts on : *hit/miss/critical* : ( + = ) +// 14 -> Initiative: : Initiative Roll : : ( + = ) +// 15 -> Dispel_Magic: Dispel Magic : : , , ... +// 17 -> Unused, probably +// 18 -> Same as 11, maybe. Might be unused too +// 19 -> Unused +// 20 -> Unused +*/ + +/// @} + +/// @name Feedback Message Types +/// @anchor feedback_msgs +/// @{ + +const int NWNX_FEEDBACK_SKILL_CANT_USE = 0; +/* +/// Skill Feedback Messages +const int NWNX_FEEDBACK_SKILL_CANT_USE_TIMER = 1; +const int NWNX_FEEDBACK_SKILL_ANIMALEMPATHY_VALID_TARGETS = 2; +const int NWNX_FEEDBACK_SKILL_TAUNT_VALID_TARGETS = 3; +const int NWNX_FEEDBACK_SKILL_TAUNT_TARGET_IMMUNE = 223; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_STOLE_ITEM = 4; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_STOLE_GOLD = 5; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_ATTEMPTING_TO_STEAL = 46; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_ATTEMPT_DETECTED = 150; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_STOLE_ITEM_TARGET = 47; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_STOLE_GOLD_TARGET = 48; +const int NWNX_FEEDBACK_SKILL_PICKPOCKET_TARGET_BROKE = 57; +const int NWNX_FEEDBACK_SKILL_HEAL_TARGET_NOT_DISPSND = 55; +const int NWNX_FEEDBACK_SKILL_HEAL_VALID_TARGETS = 56; +const int NWNX_FEEDBACK_SKILL_STEALTH_IN_COMBAT = 60; + +/// Miscellaneous Targetting Messages +const int NWNX_FEEDBACK_TARGET_UNAWARE = 6; +const int NWNX_FEEDBACK_ACTION_NOT_POSSIBLE_STATUS = 7; +const int NWNX_FEEDBACK_ACTION_NOT_POSSIBLE_PVP = 187; +const int NWNX_FEEDBACK_ACTION_CANT_REACH_TARGET = 218; +const int NWNX_FEEDBACK_ACTION_NO_LOOT = 247; + +/// Miscellaneous Feedback Messages +const int NWNX_FEEDBACK_WEIGHT_TOO_ENCUMBERED_TO_RUN = 8; +const int NWNX_FEEDBACK_WEIGHT_TOO_ENCUMBERED_WALK_SLOW = 9; +const int NWNX_FEEDBACK_WEIGHT_TOO_ENCUMBERED_CANT_PICKUP = 10; +const int NWNX_FEEDBACK_STATS_LEVELUP = 11; +const int NWNX_FEEDBACK_INVENTORY_FULL = 12; +const int NWNX_FEEDBACK_CONTAINER_FULL = 212; +const int NWNX_FEEDBACK_TRAP_TRIGGERED = 82; +const int NWNX_FEEDBACK_DAMAGE_HEALED = 151; +const int NWNX_FEEDBACK_EXPERIENCE_GAINNED = 182; +const int NWNX_FEEDBACK_EXPERIENCE_LOST = 183; +const int NWNX_FEEDBACK_JOURNALUPDATED = 184; // Doesn't actually work, use: + // NWNX_Feedback_{Get/Set}JournalUpdatedMessageHidden() +const int NWNX_FEEDBACK_BARTER_CANCELLED = 185; + +/// Mode activation/deactivation Messages +const int NWNX_FEEDBACK_DETECT_MODE_ACTIVATED = 83; +const int NWNX_FEEDBACK_DETECT_MODE_DEACTIVATED = 84; +const int NWNX_FEEDBACK_STEALTH_MODE_ACTIVATED = 85; +const int NWNX_FEEDBACK_STEALTH_MODE_DEACTIVATED = 86; +const int NWNX_FEEDBACK_PARRY_MODE_ACTIVATED = 87; +const int NWNX_FEEDBACK_PARRY_MODE_DEACTIVATED = 88; +const int NWNX_FEEDBACK_POWER_ATTACK_MODE_ACTIVATED = 89; +const int NWNX_FEEDBACK_POWER_ATTACK_MODE_DEACTIVATED = 90; +const int NWNX_FEEDBACK_IMPROVED_POWER_ATTACK_MODE_ACTIVATED = 91; +const int NWNX_FEEDBACK_IMPROVED_POWER_ATTACK_MODE_DEACTIVATED = 92; +const int NWNX_FEEDBACK_RAPID_SHOT_MODE_ACTIVATED = 166; +const int NWNX_FEEDBACK_RAPID_SHOT_MODE_DEACTIVATED = 167; +const int NWNX_FEEDBACK_FLURRY_OF_BLOWS_MODE_ACTIVATED = 168; +const int NWNX_FEEDBACK_FLURRY_OF_BLOWS_MODE_DEACTIVATED = 169; +const int NWNX_FEEDBACK_EXPERTISE_MODE_ACTIVATED = 227; +const int NWNX_FEEDBACK_EXPERTISE_MODE_DEACTIVATED = 228; +const int NWNX_FEEDBACK_IMPROVED_EXPERTISE_MODE_ACTIVATED = 229; +const int NWNX_FEEDBACK_IMPROVED_EXPERTISE_MODE_DEACTIVATED = 230; +const int NWNX_FEEDBACK_DEFENSIVE_CAST_MODE_ACTIVATED = 231; +const int NWNX_FEEDBACK_DEFENSIVE_CAST_MODE_DEACTIVATED = 232; +const int NWNX_FEEDBACK_MODE_CANNOT_USE_WEAPONS = 188; +const int NWNX_FEEDBACK_DIRTY_FIGHTING_MODE_ACTIVATED = 237; +const int NWNX_FEEDBACK_DIRTY_FIGHTING_MODE_DEACTIVATED = 238; + +const int NWNX_FEEDBACK_DEFENSIVE_STANCE_MODE_ACTIVATED = 252; +const int NWNX_FEEDBACK_DEFENSIVE_STANCE_MODE_DEACTIVATED = 253; + +/// Equipping Feedback Messages +const int NWNX_FEEDBACK_EQUIP_SKILL_SPELL_MODIFIERS = 71; +const int NWNX_FEEDBACK_EQUIP_UNIDENTIFIED = 76; +const int NWNX_FEEDBACK_EQUIP_MONK_ABILITIES = 77; +const int NWNX_FEEDBACK_EQUIP_INSUFFICIENT_LEVEL = 98; +const int NWNX_FEEDBACK_EQUIP_PROFICIENCIES = 119; +const int NWNX_FEEDBACK_EQUIP_WEAPON_TOO_LARGE = 120; +const int NWNX_FEEDBACK_EQUIP_WEAPON_TOO_SMALL = 260; +const int NWNX_FEEDBACK_EQUIP_ONE_HANDED_WEAPON = 121; +const int NWNX_FEEDBACK_EQUIP_TWO_HANDED_WEAPON = 122; +const int NWNX_FEEDBACK_EQUIP_WEAPON_SWAPPED_OUT = 123; +const int NWNX_FEEDBACK_EQUIP_ONE_CHAIN_WEAPON = 124; +const int NWNX_FEEDBACK_EQUIP_NATURAL_AC_NO_STACK = 189; +const int NWNX_FEEDBACK_EQUIP_ARMOUR_AC_NO_STACK = 190; +const int NWNX_FEEDBACK_EQUIP_SHIELD_AC_NO_STACK = 191; +const int NWNX_FEEDBACK_EQUIP_DEFLECTION_AC_NO_STACK = 192; +const int NWNX_FEEDBACK_EQUIP_NO_ARMOR_COMBAT = 193; +const int NWNX_FEEDBACK_EQUIP_RANGER_ABILITIES = 200; +const int NWNX_FEEDBACK_EQUIP_ALIGNMENT = 207; +const int NWNX_FEEDBACK_EQUIP_CLASS = 208; +const int NWNX_FEEDBACK_EQUIP_RACE = 209; +const int NWNX_FEEDBACK_UNEQUIP_NO_ARMOR_COMBAT = 194; + +/// Action Feedback Messages +const int NWNX_FEEDBACK_OBJECT_LOCKED = 13; +const int NWNX_FEEDBACK_OBJECT_NOT_LOCKED = 14; +const int NWNX_FEEDBACK_OBJECT_SPECIAL_KEY = 15; +const int NWNX_FEEDBACK_OBJECT_USED_KEY = 16; +const int NWNX_FEEDBACK_REST_EXCITED_CANT_REST = 17; +const int NWNX_FEEDBACK_REST_BEGINNING_REST = 18; +const int NWNX_FEEDBACK_REST_FINISHED_REST = 19; +const int NWNX_FEEDBACK_REST_CANCEL_REST = 20; +const int NWNX_FEEDBACK_REST_NOT_ALLOWED_IN_AREA = 54; +const int NWNX_FEEDBACK_REST_NOT_ALLOWED_BY_POSSESSED_FAMILIAR = 153; +const int NWNX_FEEDBACK_REST_NOT_ALLOWED_ENEMIES = 186; +const int NWNX_FEEDBACK_REST_CANT_UNDER_THIS_EFFECT = 213; +const int NWNX_FEEDBACK_CAST_LOST_TARGET = 21; +const int NWNX_FEEDBACK_CAST_CANT_CAST = 22; +const int NWNX_FEEDBACK_CAST_CNTRSPELL_TARGET_LOST_TARGET = 52; +const int NWNX_FEEDBACK_CAST_ARCANE_SPELL_FAILURE = 61; +const int NWNX_FEEDBACK_CAST_CNTRSPELL_TARGET_ARCANE_SPELL_FAILURE = 118; +const int NWNX_FEEDBACK_CAST_ENTANGLE_CONCENTRATION_FAILURE = 65; +const int NWNX_FEEDBACK_CAST_CNTRSPELL_TARGET_ENTANGLE_CONCENTRATION_FAILURE = 147; +const int NWNX_FEEDBACK_CAST_SPELL_INTERRUPTED = 72; +const int NWNX_FEEDBACK_CAST_EFFECT_SPELL_FAILURE = 236; +const int NWNX_FEEDBACK_CAST_CANT_CAST_WHILE_POLYMORPHED = 107; +const int NWNX_FEEDBACK_CAST_USE_HANDS = 210; +const int NWNX_FEEDBACK_CAST_USE_MOUTH = 211; +const int NWNX_FEEDBACK_CAST_DEFCAST_CONCENTRATION_FAILURE = 233; +const int NWNX_FEEDBACK_CAST_DEFCAST_CONCENTRATION_SUCCESS = 240; +const int NWNX_FEEDBACK_USEITEM_CANT_USE = 23; +const int NWNX_FEEDBACK_CONVERSATION_TOOFAR = 58; +const int NWNX_FEEDBACK_CONVERSATION_BUSY = 59; +const int NWNX_FEEDBACK_CONVERSATION_IN_COMBAT = 152; +const int NWNX_FEEDBACK_CHARACTER_INTRANSIT = 74; +const int NWNX_FEEDBACK_CHARACTER_OUTTRANSIT = 75; +const int NWNX_FEEDBACK_USEITEM_NOT_EQUIPPED = 244; +const int NWNX_FEEDBACK_DROPITEM_CANT_DROP = 245; +const int NWNX_FEEDBACK_DROPITEM_CANT_GIVE = 246; +const int NWNX_FEEDBACK_CLIENT_SERVER_SPELL_MISMATCH = 259; + +/// Combat feedback messages +const int NWNX_FEEDBACK_COMBAT_RUNNING_OUT_OF_AMMO = 24; +const int NWNX_FEEDBACK_COMBAT_OUT_OF_AMMO = 25; +const int NWNX_FEEDBACK_COMBAT_HENCHMAN_OUT_OF_AMMO = 241; +const int NWNX_FEEDBACK_COMBAT_DAMAGE_IMMUNITY = 62; +const int NWNX_FEEDBACK_COMBAT_SPELL_IMMUNITY = 68; +const int NWNX_FEEDBACK_COMBAT_DAMAGE_RESISTANCE = 63; +const int NWNX_FEEDBACK_COMBAT_DAMAGE_RESISTANCE_REMAINING = 66; +const int NWNX_FEEDBACK_COMBAT_DAMAGE_REDUCTION = 64; +const int NWNX_FEEDBACK_COMBAT_DAMAGE_REDUCTION_REMAINING = 67; +const int NWNX_FEEDBACK_COMBAT_SPELL_LEVEL_ABSORPTION = 69; +const int NWNX_FEEDBACK_COMBAT_SPELL_LEVEL_ABSORPTION_REMAINING = 70; +const int NWNX_FEEDBACK_COMBAT_WEAPON_NOT_EFFECTIVE = 117; +const int NWNX_FEEDBACK_COMBAT_EPIC_DODGE_ATTACK_EVADED = 234; +const int NWNX_FEEDBACK_COMBAT_MASSIVE_DAMAGE = 235; +const int NWNX_FEEDBACK_COMBAT_SAVED_VS_MASSIVE_DAMAGE = 254; +const int NWNX_FEEDBACK_COMBAT_SAVED_VS_DEVASTATING_CRITICAL = 257; + +/// Feat Feedback Messages +const int NWNX_FEEDBACK_FEAT_SAP_VALID_TARGETS = 26; +const int NWNX_FEEDBACK_FEAT_KNOCKDOWN_VALID_TARGETS = 27; +const int NWNX_FEEDBACK_FEAT_IMPKNOCKDOWN_VALID_TARGETS = 28; +const int NWNX_FEEDBACK_FEAT_CALLED_SHOT_NO_LEGS = 29; +const int NWNX_FEEDBACK_FEAT_CALLED_SHOT_NO_ARMS = 30; +const int NWNX_FEEDBACK_FEAT_SMITE_GOOD_TARGET_NOT_GOOD = 239; +const int NWNX_FEEDBACK_FEAT_SMITE_EVIL_TARGET_NOT_EVIL = 53; +const int NWNX_FEEDBACK_FEAT_QUIVERING_PALM_HIGHER_LEVEL = 73; +const int NWNX_FEEDBACK_FEAT_KEEN_SENSE_DETECT = 195; +const int NWNX_FEEDBACK_FEAT_USE_UNARMED = 198; +const int NWNX_FEEDBACK_FEAT_USES = 199; +const int NWNX_FEEDBACK_FEAT_USE_WEAPON_OF_CHOICE = 243; + +/// Party Feedback Messages +const int NWNX_FEEDBACK_PARTY_NEW_LEADER = 31; +const int NWNX_FEEDBACK_PARTY_MEMBER_KICKED = 32; +const int NWNX_FEEDBACK_PARTY_KICKED_YOU = 33; +const int NWNX_FEEDBACK_PARTY_ALREADY_CONSIDERING = 34; +const int NWNX_FEEDBACK_PARTY_ALREADY_INVOLVED = 35; +const int NWNX_FEEDBACK_PARTY_SENT_INVITATION = 36; +const int NWNX_FEEDBACK_PARTY_RECEIVED_INVITATION = 37; +const int NWNX_FEEDBACK_PARTY_JOINED = 38; +const int NWNX_FEEDBACK_PARTY_INVITATION_IGNORED = 39; +const int NWNX_FEEDBACK_PARTY_YOU_IGNORED_INVITATION = 40; +const int NWNX_FEEDBACK_PARTY_INVITATION_REJECTED = 41; +const int NWNX_FEEDBACK_PARTY_YOU_REJECTED_INVITATION = 42; +const int NWNX_FEEDBACK_PARTY_INVITATION_EXPIRED = 43; +const int NWNX_FEEDBACK_PARTY_LEFT_PARTY = 44; +const int NWNX_FEEDBACK_PARTY_YOU_LEFT = 45; +const int NWNX_FEEDBACK_PARTY_HENCHMAN_LIMIT = 49; +const int NWNX_FEEDBACK_PARTY_CANNOT_LEAVE_THE_ONE_PARTY = 196; +const int NWNX_FEEDBACK_PARTY_CANNOT_KICK_FROM_THE_ONE_PARTY = 197; +const int NWNX_FEEDBACK_PARTY_YOU_INVITED_NON_SINGLETON = 202; +const int NWNX_FEEDBACK_PVP_REACTION_DISLIKESYOU = 203; + +/// Item Feedback Messages +const int NWNX_FEEDBACK_ITEM_RECEIVED = 50; +const int NWNX_FEEDBACK_ITEM_LOST = 51; +const int NWNX_FEEDBACK_ITEM_EJECTED = 96; +const int NWNX_FEEDBACK_ITEM_USE_UNIDENTIFIED = 97; +const int NWNX_FEEDBACK_ITEM_GOLD_GAINED = 148; +const int NWNX_FEEDBACK_ITEM_GOLD_LOST = 149; + +/// Spell Scroll Learning +const int NWNX_FEEDBACK_LEARN_SCROLL_NOT_SCROLL = 78; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_CLASS = 79; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_LEVEL = 80; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_ABILITY = 81; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_OPPOSITION = 219; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_POSSESS = 220; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_KNOWN = 221; +const int NWNX_FEEDBACK_LEARN_SCROLL_CANT_LEARN_DIVINE = 224; +const int NWNX_FEEDBACK_LEARN_SCROLL_SUCCESS = 222; + +/// Floaty text feedback +const int NWNX_FEEDBACK_FLOATY_TEXT_STRREF = 93; +const int NWNX_FEEDBACK_FLOATY_TEXT_STRING = 94; + +/// Store feedback +const int NWNX_FEEDBACK_CANNOT_SELL_PLOT_ITEM = 99; +const int NWNX_FEEDBACK_CANNOT_SELL_CONTAINER = 100; +const int NWNX_FEEDBACK_CANNOT_SELL_ITEM = 101; +const int NWNX_FEEDBACK_NOT_ENOUGH_GOLD = 102; +const int NWNX_FEEDBACK_TRANSACTION_SUCCEEDED = 103; +const int NWNX_FEEDBACK_PRICE_TOO_HIGH = 248; +const int NWNX_FEEDBACK_STORE_NOT_ENOUGH_GOLD = 249; +const int NWNX_FEEDBACK_CANNOT_SELL_STOLEN_ITEM = 250; +const int NWNX_FEEDBACK_CANNOT_SELL_RESTRICTED_ITEM = 251; + +/// Portal control feedback +const int NWNX_FEEDBACK_PORTAL_TIMEDOUT = 104; +const int NWNX_FEEDBACK_PORTAL_INVALID = 105; + +/// Chat feedback +const int NWNX_FEEDBACK_CHAT_TELL_PLAYER_NOT_FOUND = 106; + +/// Alignment Feedback +const int NWNX_FEEDBACK_ALIGNMENT_SHIFT = 108; +const int NWNX_FEEDBACK_ALIGNMENT_PARTY_SHIFT = 111; +const int NWNX_FEEDBACK_ALIGNMENT_CHANGE = 109; +const int NWNX_FEEDBACK_ALIGNMENT_RESTRICTED_BY_CLASS_LOST = 110; +const int NWNX_FEEDBACK_ALIGNMENT_RESTRICTED_BY_CLASS_GAIN = 115; +const int NWNX_FEEDBACK_ALIGNMENT_RESTRICTED_WARNING_LOSS = 116; +const int NWNX_FEEDBACK_ALIGNMENT_RESTRICTED_WARNING_GAIN = 112; +const int NWNX_FEEDBACK_ALIGNMENT_EPITOME_GAINED = 113; +const int NWNX_FEEDBACK_ALIGNMENT_EPITOME_LOST = 114; + +/// Immunity Feedback +const int NWNX_FEEDBACK_IMMUNITY_DISEASE = 125; +const int NWNX_FEEDBACK_IMMUNITY_CRITICAL_HIT = 126; +const int NWNX_FEEDBACK_IMMUNITY_DEATH_MAGIC = 127; +const int NWNX_FEEDBACK_IMMUNITY_FEAR = 128; +const int NWNX_FEEDBACK_IMMUNITY_KNOCKDOWN = 129; +const int NWNX_FEEDBACK_IMMUNITY_PARALYSIS = 130; +const int NWNX_FEEDBACK_IMMUNITY_NEGATIVE_LEVEL = 131; +const int NWNX_FEEDBACK_IMMUNITY_MIND_SPELLS = 132; +const int NWNX_FEEDBACK_IMMUNITY_POISON = 133; +const int NWNX_FEEDBACK_IMMUNITY_SNEAK_ATTACK = 134; +const int NWNX_FEEDBACK_IMMUNITY_SLEEP = 135; +const int NWNX_FEEDBACK_IMMUNITY_DAZE = 136; +const int NWNX_FEEDBACK_IMMUNITY_CONFUSION = 137; +const int NWNX_FEEDBACK_IMMUNITY_STUN = 138; +const int NWNX_FEEDBACK_IMMUNITY_BLINDNESS = 139; +const int NWNX_FEEDBACK_IMMUNITY_DEAFNESS = 140; +const int NWNX_FEEDBACK_IMMUNITY_CURSE = 141; +const int NWNX_FEEDBACK_IMMUNITY_CHARM = 142; +const int NWNX_FEEDBACK_IMMUNITY_DOMINATE = 143; +const int NWNX_FEEDBACK_IMMUNITY_ENTANGLE = 144; +const int NWNX_FEEDBACK_IMMUNITY_SILENCE = 145; +const int NWNX_FEEDBACK_IMMUNITY_SLOW = 146; + +/// Associates +const int NWNX_FEEDBACK_ASSOCIATE_SUMMONED = 154; +const int NWNX_FEEDBACK_ASSOCIATE_UNSUMMONING = 155; +const int NWNX_FEEDBACK_ASSOCIATE_UNSUMMONING_BECAUSE_REST = 156; +const int NWNX_FEEDBACK_ASSOCIATE_UNSUMMONING_BECAUSE_DIED = 157; +const int NWNX_FEEDBACK_ASSOCIATE_DOMINATED = 158; +const int NWNX_FEEDBACK_ASSOCIATE_DOMINATION_ENDED = 159; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_RECOVER_TRAP = 170; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_BARTER = 171; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_EQUIP = 172; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_REPOSITORY_MOVE = 173; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_PICK_UP = 174; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_DROP = 175; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_UNEQUIP = 176; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_REST = 177; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_DIALOGUE = 178; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_GIVE_ITEM = 179; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_TAKE_ITEM = 180; +const int NWNX_FEEDBACK_ASSOCIATE_POSSESSED_CANNOT_USE_CONTAINER = 181; + +/// Miscellaneous Feedback +const int NWNX_FEEDBACK_SCRIPT_ERROR = 160; +const int NWNX_FEEDBACK_ACTION_LIST_OVERFLOW = 161; +const int NWNX_FEEDBACK_EFFECT_LIST_OVERFLOW = 162; +const int NWNX_FEEDBACK_AI_UPDATE_TIME_OVERFLOW = 163; +const int NWNX_FEEDBACK_ACTION_LIST_WIPE_OVERFLOW = 164; +const int NWNX_FEEDBACK_EFFECT_LIST_WIPE_OVERFLOW = 165; +const int NWNX_FEEDBACK_SEND_MESSAGE_TO_PC = 204; +const int NWNX_FEEDBACK_SEND_MESSAGE_TO_PC_STRREF = 242; + +/// Misc GUI feedback +const int NWNX_FEEDBACK_GUI_ONLY_PARTY_LEADER_MAY_CLICK = 201; +const int NWNX_FEEDBACK_PAUSED = 205; +const int NWNX_FEEDBACK_UNPAUSED = 206; +const int NWNX_FEEDBACK_REST_YOU_MAY_NOT_AT_THIS_TIME = 214; +const int NWNX_FEEDBACK_GUI_CHAR_EXPORT_REQUEST_SENT = 215; +const int NWNX_FEEDBACK_GUI_CHAR_EXPORTED_SUCCESSFULLY = 216; +const int NWNX_FEEDBACK_GUI_ERROR_CHAR_NOT_EXPORTED = 217; +const int NWNX_FEEDBACK_CAMERA_BG = 255; +const int NWNX_FEEDBACK_CAMERA_EQ = 256; +const int NWNX_FEEDBACK_CAMERA_CHASECAM = 258; + +const int NWNX_FEEDBACK_SAVING = 225; +const int NWNX_FEEDBACK_SAVE_COMPLETE = 226; +*/ +/// @} + +/// @brief Gets if feedback message is hidden. +/// @param nMessage The message identifier from @ref feedback_msgs "Feedback Messages". +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @return TRUE if the message is hidden. +int NWNX_Feedback_GetFeedbackMessageHidden(int nMessage, object oPC = OBJECT_INVALID); + +/// @brief Sets if feedback message is hidden. +/// @param nMessage The message identifier. +/// @param isHidden TRUE/FALSE +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @note Personal state overrides the global state which means if a global state is set +/// to TRUE but the personal state is set to FALSE, the message will be shown to the PC. +void NWNX_Feedback_SetFeedbackMessageHidden(int nMessage, int isHidden, object oPC = OBJECT_INVALID); + +/// @brief Gets if combat log message is hidden. +/// @param nMessage The message identifier from @ref combat_log_msgs "Combat Log Messages". +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @return TRUE if the message is hidden. +int NWNX_Feedback_GetCombatLogMessageHidden(int nMessage, object oPC = OBJECT_INVALID); + +/// @brief Sets if combat log message is hidden. +/// @param nMessage The message identifier. +/// @param isHidden TRUE/FALSE +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @note Personal state overrides the global state which means if a global state is set +/// to TRUE but the personal state is set to FALSE, the message will be shown to the PC. +void NWNX_Feedback_SetCombatLogMessageHidden(int nMessage, int isHidden, object oPC = OBJECT_INVALID); + +/// @brief Gets if the journal update message is hidden. +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @return TRUE if the message is hidden. +int NWNX_Feedback_GetJournalUpdatedMessageHidden(object oPC = OBJECT_INVALID); + +/// @brief Sets if journal update message is hidden. +/// @param isHidden TRUE/FALSE +/// @param oPC The PC or OBJECT_INVALID for a global setting. +/// @note Personal state overrides the global state which means if a global state is set +/// to TRUE but the personal state is set to FALSE, the message will be shown to the PC. +void NWNX_Feedback_SetJournalUpdatedMessageHidden(int isHidden, object oPC = OBJECT_INVALID); + +/// @brief Set whether to use a blacklist or whitelist mode for feedback messages +/// @param bWhitelist TRUE for all messages to be hidden by default, default FALSE. +void NWNX_Feedback_SetFeedbackMessageMode(int bWhitelist); + + +/// @brief Set whether to use a blacklist or whitelist mode for combat log messages +/// @param bWhitelist TRUE for all messages to be hidden by default, default FALSE. +/// @note If using Whitelist, be sure to whitelist NWNX_FEEDBACK_COMBATLOG_FEEDBACK for feedback messages to work. +void NWNX_Feedback_SetCombatLogMessageMode(int bWhitelist); + +/// @} + +int NWNX_Feedback_GetFeedbackMessageHidden(int nMessage, object oPC = OBJECT_INVALID) +{ + string sFunc = "GetMessageHidden"; + int nMessageType = 0; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessage); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Feedback, sFunc); +} + +void NWNX_Feedback_SetFeedbackMessageHidden(int nMessage, int isHidden, object oPC = OBJECT_INVALID) +{ + string sFunc = "SetMessageHidden"; + int nMessageType = 0; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, isHidden); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessage); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); +} + +int NWNX_Feedback_GetCombatLogMessageHidden(int nMessage, object oPC = OBJECT_INVALID) +{ + string sFunc = "GetMessageHidden"; + int nMessageType = 1; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessage); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Feedback, sFunc); +} + +void NWNX_Feedback_SetCombatLogMessageHidden(int nMessage, int isHidden, object oPC = OBJECT_INVALID) +{ + string sFunc = "SetMessageHidden"; + int nMessageType = 1; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, isHidden); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessage); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); +} + +int NWNX_Feedback_GetJournalUpdatedMessageHidden(object oPC = OBJECT_INVALID) +{ + string sFunc = "GetMessageHidden"; + int nMessageType = 2; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, 0); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Feedback, sFunc); +} + +void NWNX_Feedback_SetJournalUpdatedMessageHidden(int isHidden, object oPC = OBJECT_INVALID) +{ + string sFunc = "SetMessageHidden"; + int nMessageType = 2; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, isHidden); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, 0); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_PushArgumentObject(NWNX_Feedback, sFunc, oPC); + NWNX_CallFunction(NWNX_Feedback, sFunc); +} + +void NWNX_Feedback_SetFeedbackMessageMode(int bWhitelist) +{ + string sFunc = "SetFeedbackMode"; + int nMessageType = 0; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, bWhitelist); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_CallFunction(NWNX_Feedback, sFunc); +} + +void NWNX_Feedback_SetCombatLogMessageMode(int bWhitelist) +{ + string sFunc = "SetFeedbackMode"; + int nMessageType = 1; + + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, bWhitelist); + NWNX_PushArgumentInt(NWNX_Feedback, sFunc, nMessageType); + NWNX_CallFunction(NWNX_Feedback, sFunc); +} diff --git a/nwnds_module/nwnx_item.nss b/nwnds_module/nwnx_item.nss new file mode 100644 index 000000000..ce83ef868 --- /dev/null +++ b/nwnds_module/nwnx_item.nss @@ -0,0 +1,207 @@ +/// @addtogroup item Item +/// @brief Functions exposing additional item properties. +/// @{ +/// @file nwnx_item.nss +#include "nwnx" + +const string NWNX_Item = "NWNX_Item"; ///< @private + +/// @brief Set an item's weight. +/// @note Will not persist through saving. +/// @param oItem The item object. +/// @param weight The weight, note this is in tenths of pounds. +void NWNX_Item_SetWeight(object oItem, int weight); + +/// @brief Set an item's base value in gold pieces. +/// @remark Total cost = base_value + additional_value. +/// @remark Equivalent to SetGoldPieceValue NWNX2 function. +/// @note Will not persist through saving. +/// @param oItem The item object. +/// @param gold The base gold value. +void NWNX_Item_SetBaseGoldPieceValue(object oItem, int gold); + +/// @brief Set an item's additional value in gold pieces. +/// @remark Total cost = base_value + additional_value. +/// @note Will persist through saving. +/// @param oItem The item object. +/// @param gold The additional gold value. +void NWNX_Item_SetAddGoldPieceValue(object oItem, int gold); + +/// @brief Get an item's base value in gold pieces. +/// @param oItem The item object. +/// @return The base gold piece value for the item. +int NWNX_Item_GetBaseGoldPieceValue(object oItem); + +/// @brief Get an item's additional value in gold pieces. +/// @param oItem The item object. +/// @return The additional gold piece value for the item. +int NWNX_Item_GetAddGoldPieceValue(object oItem); + +/// @brief Set an item's base item type. +/// @warning This will not be visible until the item is refreshed (e.g. drop and take the item, +/// or logging out and back in). +/// @param oItem The item object. +/// @param nBaseItem The new base item. +void NWNX_Item_SetBaseItemType(object oItem, int nBaseItem); + +/// @brief Make a single change to the appearance of an item. +/// @warning This will not be visible to PCs until the item is refreshed for them (e.g. by logging out and back in). +/// +/// Helmet models and simple items ignore nIndex. +/// ``` +/// nType nIndex nValue +/// ITEM_APPR_TYPE_SIMPLE_MODEL [Ignored] Model # +/// ITEM_APPR_TYPE_WEAPON_COLOR ITEM_APPR_WEAPON_COLOR_* 0-255 +/// ITEM_APPR_TYPE_WEAPON_MODEL ITEM_APPR_WEAPON_MODEL_* Model # +/// ITEM_APPR_TYPE_ARMOR_MODEL ITEM_APPR_ARMOR_MODEL_* Model # +/// ITEM_APPR_TYPE_ARMOR_COLOR ITEM_APPR_ARMOR_COLOR_* [0] 0-255 [1] +/// ``` +/// +/// [0] Where ITEM_APPR_TYPE_ARMOR_COLOR is specified, if per-part coloring is +/// desired, the following equation can be used for nIndex to achieve that: +/// +/// ITEM_APPR_ARMOR_NUM_COLORS + (ITEM_APPR_ARMOR_MODEL_ * ITEM_APPR_ARMOR_NUM_COLORS) + ITEM_APPR_ARMOR_COLOR_ +/// +/// For example, to change the CLOTH1 channel of the torso, nIndex would be: +/// +/// 6 + (7 * 6) + 2 = 50 +/// +/// [1] When specifying per-part coloring, the value 255 corresponds with the logical +/// function 'clear colour override', which clears the per-part override for that part. +void NWNX_Item_SetItemAppearance(object oItem, int nType, int nIndex, int nValue); + +/// @brief Return a string containing the entire appearance for an item. +/// @sa NWNX_Item_RestoreItemAppearance +/// @param oItem The item object. +/// @return A string representing the item's appearance. +string NWNX_Item_GetEntireItemAppearance(object oItem); + +/// @brief Restores an item's appearance using the value retrieved through NWNX_Item_GetEntireItemAppearance(). +/// @param oItem The item object. +/// @param sApp A string representing the item's appearance. +void NWNX_Item_RestoreItemAppearance(object oItem, string sApp); + +/// @brief Get an item's base armor class +/// @param oItem The item object. +/// @return The base armor class. +int NWNX_Item_GetBaseArmorClass(object oItem); + +/// @brief Get an item's minimum level required to equip. +/// @param oItem The item object. +/// @return The minimum level required to equip the item. +int NWNX_Item_GetMinEquipLevel(object oItem); + +/// @} + +void NWNX_Item_SetWeight(object oItem, int w) +{ + string sFunc = "SetWeight"; + + NWNX_PushArgumentInt(NWNX_Item, sFunc, w); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); +} + +void NWNX_Item_SetBaseGoldPieceValue(object oItem, int g) +{ + string sFunc = "SetBaseGoldPieceValue"; + + NWNX_PushArgumentInt(NWNX_Item, sFunc, g); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); +} + +void NWNX_Item_SetAddGoldPieceValue(object oItem, int g) +{ + string sFunc = "SetAddGoldPieceValue"; + + NWNX_PushArgumentInt(NWNX_Item, sFunc, g); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); +} + +int NWNX_Item_GetBaseGoldPieceValue(object oItem) +{ + string sFunc = "GetBaseGoldPieceValue"; + + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + return NWNX_GetReturnValueInt(NWNX_Item, sFunc); +} + +int NWNX_Item_GetAddGoldPieceValue(object oItem) +{ + string sFunc = "GetAddGoldPieceValue"; + + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + return NWNX_GetReturnValueInt(NWNX_Item, sFunc); +} + +void NWNX_Item_SetBaseItemType(object oItem, int nBaseItem) +{ + string sFunc = "SetBaseItemType"; + + NWNX_PushArgumentInt(NWNX_Item, sFunc, nBaseItem); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); +} + +void NWNX_Item_SetItemAppearance(object oItem, int nType, int nIndex, int nValue) +{ + string sFunc = "SetItemAppearance"; + + NWNX_PushArgumentInt(NWNX_Item, sFunc, nValue); + NWNX_PushArgumentInt(NWNX_Item, sFunc, nIndex); + NWNX_PushArgumentInt(NWNX_Item, sFunc, nType); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + +} + +string NWNX_Item_GetEntireItemAppearance(object oItem) +{ + string sFunc = "GetEntireItemAppearance"; + + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + return NWNX_GetReturnValueString(NWNX_Item, sFunc); +} + +void NWNX_Item_RestoreItemAppearance(object oItem, string sApp) +{ + string sFunc = "RestoreItemAppearance"; + + NWNX_PushArgumentString(NWNX_Item, sFunc, sApp); + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); +} + +int NWNX_Item_GetBaseArmorClass(object oItem) +{ + string sFunc = "GetBaseArmorClass"; + + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + return NWNX_GetReturnValueInt(NWNX_Item, sFunc); +} + +int NWNX_Item_GetMinEquipLevel(object oItem) +{ + string sFunc = "GetMinEquipLevel"; + + NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); + + NWNX_CallFunction(NWNX_Item, sFunc); + return NWNX_GetReturnValueInt(NWNX_Item, sFunc); +} diff --git a/nwnds_module/nwnx_itemprop.nss b/nwnds_module/nwnx_itemprop.nss new file mode 100644 index 000000000..5385c3506 --- /dev/null +++ b/nwnds_module/nwnx_itemprop.nss @@ -0,0 +1,110 @@ +/// @addtogroup itemproperty ItemProperty +/// @brief Utility functions to manipulate the builtin itemproperty type. +/// @{ +/// @file nwnx_itemprop.nss +#include "nwnx" + +const string NWNX_ItemProperty = "NWNX_ItemProperty"; ///< @private + +/// @brief An unpacked itemproperty. +struct NWNX_IPUnpacked +{ + int nProperty; ///< @todo Describe + int nSubType; ///< @todo Describe + int nCostTable; ///< @todo Describe + int nCostTableValue; ///< @todo Describe + int nParam1; ///< @todo Describe + int nParam1Value; ///< @todo Describe + int nUsesPerDay; ///< @todo Describe + int nChanceToAppear; ///< @todo Describe + int bUsable; ///< @todo Describe + int nSpellId; ///< @todo Describe + object oCreator; ///< @todo Describe + string sTag; ///< @todo Describe +}; + +/// @brief Convert native itemproperty type to unpacked structure. +/// @param ip The itemproperty to convert. +/// @return A constructed NWNX_IPUnpacked. +struct NWNX_IPUnpacked NWNX_ItemProperty_UnpackIP(itemproperty ip); + +/// @brief Convert unpacked itemproperty structure to native type. +/// @param ip The NWNX_IPUnpacked structure to convert. +/// @return The itemproperty. +itemproperty NWNX_ItemProperty_PackIP(struct NWNX_IPUnpacked ip); + +/// @brief Gets the active item property at the index +/// @param oItem - the item with the property +/// @param nIndex - the index such as returned by some Item Events +/// @return A constructed NWNX_IPUnpacked, except for creator, and spell id. +struct NWNX_IPUnpacked NWNX_ItemProperty_GetActiveProperty(object oItem, int nIndex); + +/// @} + +struct NWNX_IPUnpacked NWNX_ItemProperty_UnpackIP(itemproperty ip) +{ + string sFunc = "UnpackIP"; + + NWNX_PushArgumentItemProperty(NWNX_ItemProperty, sFunc, ip); + NWNX_CallFunction(NWNX_ItemProperty, sFunc); + + struct NWNX_IPUnpacked n; + + n.nProperty = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nSubType = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nCostTable = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nCostTableValue = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nParam1 = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nParam1Value = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nUsesPerDay = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nChanceToAppear = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.bUsable = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nSpellId = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.oCreator = NWNX_GetReturnValueObject(NWNX_ItemProperty, sFunc); + n.sTag = NWNX_GetReturnValueString(NWNX_ItemProperty, sFunc); + + return n; +} +itemproperty NWNX_ItemProperty_PackIP(struct NWNX_IPUnpacked n) +{ + string sFunc = "PackIP"; + + NWNX_PushArgumentString(NWNX_ItemProperty, sFunc, n.sTag); + NWNX_PushArgumentObject(NWNX_ItemProperty, sFunc, n.oCreator); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nSpellId); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.bUsable); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nChanceToAppear); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nUsesPerDay); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nParam1Value); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nParam1); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nCostTableValue); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nCostTable); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nSubType); + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, n.nProperty); + + NWNX_CallFunction(NWNX_ItemProperty, sFunc); + return NWNX_GetReturnValueItemProperty(NWNX_ItemProperty, sFunc); +} + +struct NWNX_IPUnpacked NWNX_ItemProperty_GetActiveProperty(object oItem, int nIndex) +{ + string sFunc = "GetActiveProperty"; + NWNX_PushArgumentInt(NWNX_ItemProperty, sFunc, nIndex); + NWNX_PushArgumentObject(NWNX_ItemProperty, sFunc, oItem); + NWNX_CallFunction(NWNX_ItemProperty, sFunc); + + struct NWNX_IPUnpacked n; + + n.nProperty = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nSubType = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nCostTable = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nCostTableValue = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nParam1 = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nParam1Value = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nUsesPerDay = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.nChanceToAppear = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.bUsable = NWNX_GetReturnValueInt(NWNX_ItemProperty, sFunc); + n.sTag = NWNX_GetReturnValueString(NWNX_ItemProperty, sFunc); + + return n; +} \ No newline at end of file diff --git a/nwnds_module/nwnx_lua.nss b/nwnds_module/nwnx_lua.nss new file mode 100644 index 000000000..70eb707e2 --- /dev/null +++ b/nwnds_module/nwnx_lua.nss @@ -0,0 +1,51 @@ +/// @addtogroup lua LUA +/// @brief Execute Lua code and generate events in NWScript +/// @{ +/// @file nwnx_lua.nss +#include "nwnx" + +const string NWNX_Lua = "NWNX_Lua"; ///< @private + +/// @brief Evaluate LUA code. +/// @param sCode The code to evaluate. +void NWNX_Lua_EvalVoid(string sCode); + +/// @brief Evaluate LUA code and return the output. +/// @param sCode The code to evaluate. +/// @return The result of the Lua code execution. +string NWNX_Lua_Eval(string sCode); + +/// @brief Generate events in NWScript to receive on the Lua side. +/// +/// Executes all the Lua functions registered to listen to that event in order of priority. +/// For details on events just look at the three *Event() functions in preload.lua. +void NWNX_Lua_RunEvent(string sEvent, object oObject, string sExtra=""); + +/// @} + +void NWNX_Lua_EvalVoid(string sCode) +{ + string sFunc = "EvalVoid"; + + NWNX_PushArgumentString(NWNX_Lua, sFunc, sCode); + NWNX_CallFunction(NWNX_Lua, sFunc); +} + +string NWNX_Lua_Eval(string sCode) +{ + string sFunc = "Eval"; + + NWNX_PushArgumentString(NWNX_Lua, sFunc, sCode); + NWNX_CallFunction(NWNX_Lua, sFunc); + return NWNX_GetReturnValueString(NWNX_Lua, sFunc); +} + +void NWNX_Lua_RunEvent(string sEvent, object oObject, string sExtra="") +{ + string sFunc = "RunEvent"; + + NWNX_PushArgumentString(NWNX_Lua, sFunc, sExtra); + NWNX_PushArgumentObject(NWNX_Lua, sFunc, oObject); + NWNX_PushArgumentString(NWNX_Lua, sFunc, sEvent); + NWNX_CallFunction(NWNX_Lua, sFunc); +} diff --git a/nwnds_module/nwnx_object.nss b/nwnds_module/nwnx_object.nss new file mode 100644 index 000000000..e6f4eeacd --- /dev/null +++ b/nwnds_module/nwnx_object.nss @@ -0,0 +1,834 @@ +/// @addtogroup object Object +/// @brief Functions exposing additional object properties. +/// @{ +/// @file nwnx_object.nss +#include "nwnx" + +const string NWNX_Object = "NWNX_Object"; ///< @private + +/// @anchor object_localvar_types +/// @name Local Variable Types +/// @{ +const int NWNX_OBJECT_LOCALVAR_TYPE_UNKNOWN = 0; +const int NWNX_OBJECT_LOCALVAR_TYPE_INT = 1; +const int NWNX_OBJECT_LOCALVAR_TYPE_FLOAT = 2; +const int NWNX_OBJECT_LOCALVAR_TYPE_STRING = 3; +const int NWNX_OBJECT_LOCALVAR_TYPE_OBJECT = 4; +const int NWNX_OBJECT_LOCALVAR_TYPE_LOCATION = 5; +/// @} + +/// @anchor object_internal_types +/// @name Internal Object Types +/// @{ +const int NWNX_OBJECT_TYPE_INTERNAL_INVALID = -1; +const int NWNX_OBJECT_TYPE_INTERNAL_GUI = 1; +const int NWNX_OBJECT_TYPE_INTERNAL_TILE = 2; +const int NWNX_OBJECT_TYPE_INTERNAL_MODULE = 3; +const int NWNX_OBJECT_TYPE_INTERNAL_AREA = 4; +const int NWNX_OBJECT_TYPE_INTERNAL_CREATURE = 5; +const int NWNX_OBJECT_TYPE_INTERNAL_ITEM = 6; +const int NWNX_OBJECT_TYPE_INTERNAL_TRIGGER = 7; +const int NWNX_OBJECT_TYPE_INTERNAL_PROJECTILE = 8; +const int NWNX_OBJECT_TYPE_INTERNAL_PLACEABLE = 9; +const int NWNX_OBJECT_TYPE_INTERNAL_DOOR = 10; +const int NWNX_OBJECT_TYPE_INTERNAL_AREAOFEFFECT = 11; +const int NWNX_OBJECT_TYPE_INTERNAL_WAYPOINT = 12; +const int NWNX_OBJECT_TYPE_INTERNAL_ENCOUNTER = 13; +const int NWNX_OBJECT_TYPE_INTERNAL_STORE = 14; +const int NWNX_OBJECT_TYPE_INTERNAL_PORTAL = 15; +const int NWNX_OBJECT_TYPE_INTERNAL_SOUND = 16; +/// @} + +/// A local variable structure. +struct NWNX_Object_LocalVariable +{ + int type; ///< Int, String, Float, Object + string key; ///< Name of the variable +}; + +/// @brief Gets the count of all local variables. +/// @param obj The object. +/// @return The count. +int NWNX_Object_GetLocalVariableCount(object obj); + +/// @brief Gets the local variable at the provided index of the provided object. +/// @param obj The object. +/// @param index The index. +/// @note Index bounds: 0 >= index < NWNX_Object_GetLocalVariableCount(). +/// @note As of build 8193.14 local variables no longer have strict ordering. +/// this means that any change to the variables can result in drastically +/// different order when iterating. +/// @note As of build 8193.14, this function takes O(n) time, where n is the number +/// of locals on the object. Individual variable access with GetLocalXxx() +/// is now O(1) though. +/// @note As of build 8193.14, this function may return variable type UNKNOWN +/// if the value is the default (0/0.0/""/OBJECT_INVALID) for the type. +/// @return An NWNX_Object_LocalVariable struct. +struct NWNX_Object_LocalVariable NWNX_Object_GetLocalVariable(object obj, int index); + +/// @brief Convert an object id to the actual object. +/// @param id The object id. +/// @return An object from the provided object ID. +/// @remark This is the counterpart to ObjectToString. +/// @deprecated Use the basegame StringToObject() function. This will be removed in a future NWNX release. +object NWNX_Object_StringToObject(string id); + +/// @brief Set oObject's position. +/// @param oObject The object. +/// @param vPosition A vector position. +/// @param bUpdateSubareas If TRUE and oObject is a creature, any triggers/traps at vPosition will fire their events. +void NWNX_Object_SetPosition(object oObject, vector vPosition, int bUpdateSubareas = TRUE); + +/// @brief Get an object's hit points. +/// @note Unlike the native GetCurrentHitpoints function, this excludes temporary hitpoints. +/// @param obj The object. +/// @return The hit points. +int NWNX_Object_GetCurrentHitPoints(object obj); + +/// @brief Set an object's hit points. +/// @param obj The object. +/// @param hp The hit points. +void NWNX_Object_SetCurrentHitPoints(object obj, int hp); + +/// @brief Adjust an object's maximum hit points +/// @note Will not work on PCs. +/// @param obj The object. +/// @param hp The maximum hit points. +void NWNX_Object_SetMaxHitPoints(object obj, int hp); + +/// @brief Serialize a full object to a base64 string +/// @param obj The object. +/// @return A base64 string representation of the object. +/// @note includes locals, inventory, etc +string NWNX_Object_Serialize(object obj); + +/// @brief Deserialize the object. +/// @note The object will be created outside of the world and needs to be manually positioned at a location/inventory. +/// @param serialized The base64 string. +/// @return The object. +object NWNX_Object_Deserialize(string serialized); + +/// @brief Gets the dialog resref. +/// @param obj The object. +/// @return The name of the dialog resref. +string NWNX_Object_GetDialogResref(object obj); + +/// @brief Sets the dialog resref. +/// @param obj The object. +/// @param dialog The name of the dialog resref. +void NWNX_Object_SetDialogResref(object obj, string dialog); + +/// @brief Set oPlaceable's appearance. +/// @note Will not update for PCs until they re-enter the area. +/// @param oPlaceable The placeable. +/// @param nAppearance The appearance id. +void NWNX_Object_SetAppearance(object oPlaceable, int nAppearance); + +/// @brief Get oPlaceable's appearance. +/// @param oPlaceable The placeable. +/// @return The appearance id. +int NWNX_Object_GetAppearance(object oPlaceable); + +/// @brief Determine if an object has a visual effect. +/// @param obj The object. +/// @param nVFX The visual effect id. +/// @return TRUE if the object has the visual effect applied to it +int NWNX_Object_GetHasVisualEffect(object obj, int nVFX); + +/// @brief Check if an item can fit in an object's inventory. +/// @param obj The object with an inventory. +/// @param baseitem The base item id to check for a fit. +/// @return TRUE if an item of base item type can fit in object's inventory +int NWNX_Object_CheckFit(object obj, int baseitem); + +/// @brief Get an object's damage immunity. +/// @param obj The object. +/// @param damageType The damage type to check for immunity. Use DAMAGE_TYPE_* constants. +/// @return Damage immunity as a percentage. +int NWNX_Object_GetDamageImmunity(object obj, int damageType); + +/// @brief Add or move an object. +/// @param obj The object. +/// @param area The area. +/// @param pos The position. +void NWNX_Object_AddToArea(object obj, object area, vector pos); + +/// @brief Get placeable's static setting +/// @param obj The object. +/// @return TRUE if placeable is static. +int NWNX_Object_GetPlaceableIsStatic(object obj); + +/// @brief Set placeable as static or not. +/// @note Will not update for PCs until they re-enter the area. +/// @param obj The object. +/// @param isStatic TRUE/FALSE +void NWNX_Object_SetPlaceableIsStatic(object obj, int isStatic); + +/// @brief Gets if a door/placeable auto-removes the key after use. +/// @param obj The object. +/// @return TRUE/FALSE or -1 on error. +int NWNX_Object_GetAutoRemoveKey(object obj); + +/// @brief Sets if a door/placeable auto-removes the key after use. +/// @param obj The object. +/// @param bRemoveKey TRUE/FALSE +void NWNX_Object_SetAutoRemoveKey(object obj, int bRemoveKey); + +/// @brief Get the geometry of a trigger +/// @param oTrigger The trigger object. +/// @return A string of vertex positions. +string NWNX_Object_GetTriggerGeometry(object oTrigger); + +/// @brief Set the geometry of a trigger with a list of vertex positions +/// @param oTrigger The trigger object. +/// @param sGeometry Needs to be in the following format -> {x.x, y.y, z.z} or {x.x, y.y} +/// Example Geometry: "{1.0, 1.0, 0.0}{4.0, 1.0, 0.0}{4.0, 4.0, 0.0}{1.0, 4.0, 0.0}" +/// +/// @remark The Z position is optional and will be calculated dynamically based +/// on terrain height if it's not provided. +/// +/// @remark The minimum number of vertices is 3. +void NWNX_Object_SetTriggerGeometry(object oTrigger, string sGeometry); + +/// @brief Add an effect to an object that displays an icon and has no other effect. +/// @remark See effecticons.2da for a list of possible effect icons. +/// @param obj The object to apply the effect. +/// @param nIcon The icon id. +/// @param fDuration If specified the effect will be temporary and last this length in seconds, otherwise the effect +/// will be permanent. +void NWNX_Object_AddIconEffect(object obj, int nIcon, float fDuration=0.0); + +/// @brief Remove an icon effect from an object that was added by the NWNX_Object_AddIconEffect() function. +/// @param obj The object. +/// @param nIcon The icon id. +void NWNX_Object_RemoveIconEffect(object obj, int nIcon); + +/// @brief Export an object to the UserDirectory/nwnx folder. +/// @param sFileName The filename without extension, 16 or less characters. +/// @param oObject The object to export. Valid object types: Creature, Item, Placeable, Waypoint, Door, Store, Trigger +void NWNX_Object_Export(string sFileName, object oObject); + +/// @brief Get oObject's integer variable sVarName. +/// @param oObject The object to get the variable from. +/// @param sVarName The variable name. +/// @return The value or 0 on error. +int NWNX_Object_GetInt(object oObject, string sVarName); + +/// @brief Set oObject's integer variable sVarName to nValue. +/// @param oObject The object to set the variable on. +/// @param sVarName The variable name. +/// @param nValue The integer value to to set +/// @param bPersist When TRUE, the value is persisted to GFF, this means that it'll be saved in the .bic file of a player's character or when an object is serialized. +void NWNX_Object_SetInt(object oObject, string sVarName, int nValue, int bPersist); + +/// @brief Delete oObject's integer variable sVarName. +/// @param oObject The object to delete the variable from. +/// @param sVarName The variable name. +void NWNX_Object_DeleteInt(object oObject, string sVarName); + +/// @brief Get oObject's string variable sVarName. +/// @param oObject The object to get the variable from. +/// @param sVarName The variable name. +/// @return The value or "" on error. +string NWNX_Object_GetString(object oObject, string sVarName); + +/// @brief Set oObject's string variable sVarName to sValue. +/// @param oObject The object to set the variable on. +/// @param sVarName The variable name. +/// @param sValue The string value to to set +/// @param bPersist When TRUE, the value is persisted to GFF, this means that it'll be saved in the .bic file of a player's character or when an object is serialized. +void NWNX_Object_SetString(object oObject, string sVarName, string sValue, int bPersist); + +/// @brief Delete oObject's string variable sVarName. +/// @param oObject The object to delete the variable from. +/// @param sVarName The variable name. +void NWNX_Object_DeleteString(object oObject, string sVarName); + +/// @brief Get oObject's float variable sVarName. +/// @param oObject The object to get the variable from. +/// @param sVarName The variable name. +/// @return The value or 0.0f on error. +float NWNX_Object_GetFloat(object oObject, string sVarName); + +/// @brief Set oObject's float variable sVarName to fValue. +/// @param oObject The object to set the variable on. +/// @param sVarName The variable name. +/// @param fValue The float value to to set +/// @param bPersist When TRUE, the value is persisted to GFF, this means that it'll be saved in the .bic file of a player's character or when an object is serialized. +void NWNX_Object_SetFloat(object oObject, string sVarName, float fValue, int bPersist); + +/// @brief Delete oObject's persistent float variable sVarName. +/// @param oObject The object to delete the variable from. +/// @param sVarName The variable name. +void NWNX_Object_DeleteFloat(object oObject, string sVarName); + +/// @brief Delete any variables that match sRegex +/// @note It will only remove variables set by NWNX_Object_Set{Int|String|Float}() +/// @param oObject The object to delete the variables from. +/// @param sRegex The regular expression, for example .*Test.* removes every variable that has Test in it. +void NWNX_Object_DeleteVarRegex(object oObject, string sRegex); + +/// @brief Get if vPosition is inside oTrigger's geometry. +/// @note The Z value of vPosition is ignored. +/// @param oTrigger The trigger. +/// @param vPosition The position. +/// @return TRUE if vPosition is inside oTrigger's geometry. +int NWNX_Object_GetPositionIsInTrigger(object oTrigger, vector vPosition); + +/// @brief Gets the given object's internal type (NWNX_OBJECT_TYPE_INTERNAL_*) +/// @param oObject The object. +/// @return The object's type (NWNX_OBJECT_TYPE_INTERNAL_*) +int NWNX_Object_GetInternalObjectType(object oObject); + +/// @brief Have oObject acquire oItem. +/// @note Useful to give deserialized items to an object, may not work if oItem is already possessed by an object. +/// @param oObject The object receiving oItem, must be a Creature, Placeable, Store or Item +/// @param oItem The item. +/// @return TRUE on success. +int NWNX_Object_AcquireItem(object oObject, object oItem); + +/// @brief Cause oObject to face fDirection. +/// @note This function is almost identical to SetFacing(), the only difference being that it allows you to specify +/// the target object without the use of AssignCommand(). This is useful when you want to change the facing of an object +/// in an ExecuteScriptChunk() call where AssignCommand() does not work. +/// @param oObject The object to change its facing of +/// @param fDirection The direction the object should face +void NWNX_Object_SetFacing(object oObject, float fDirection); + +/// @brief Clear all spell effects oObject has applied to others. +/// @param oObject The object that applied the spell effects. +void NWNX_Object_ClearSpellEffectsOnOthers(object oObject); + +/// @brief Peek at the UUID of oObject without assigning one if it does not have one +/// @param oObject The object +/// @return The UUID or "" when the object does not have or cannot have an UUID +string NWNX_Object_PeekUUID(object oObject); + +/// @brief Get if oDoor has a visible model. +/// @param oDoor The door +/// @return TRUE if oDoor has a visible model +int NWNX_Object_GetDoorHasVisibleModel(object oDoor); + +/// @brief Get if oObject is destroyable. +/// @param oObject The object +/// @return TRUE if oObject is destroyable. +int NWNX_Object_GetIsDestroyable(object oObject); + +/// @brief Checks for specific spell immunity. Should only be called in spellscripts +/// @param oDefender The object defending against the spell. +/// @param oCaster The object casting the spell. +/// @return -1 if defender has no immunity, 2 if the defender is immune +int NWNX_Object_DoSpellImmunity(object oDefender, object oCaster); + +/// @brief Checks for spell school/level immunities and mantles. Should only be called in spellscripts +/// @param oDefender The object defending against the spell. +/// @param oCaster The object casting the spell. +/// @return -1 defender no immunity. 2 if immune. 3 if immune, but the immunity has a limit (example: mantles) +int NWNX_Object_DoSpellLevelAbsorption(object oDefender, object oCaster); + +/// @brief Sets if a placeable has an inventory. +/// @param obj The placeable. +/// @param bHasInventory TRUE/FALSE +/// @note Only works on placeables. +void NWNX_Object_SetHasInventory(object obj, int bHasInventory); + +/// @brief Get the current animation of oObject +/// @note The returned value will be an engine animation constant, not a NWScript ANIMATION_ constant. +/// See: https://github.com/nwnxee/unified/blob/master/NWNXLib/API/Constants/Animation.hpp +/// @param oObject The object +/// @return -1 on error or the engine animation constant +int NWNX_Object_GetCurrentAnimation(object oObject); + +/// @} + +int NWNX_Object_GetLocalVariableCount(object obj) +{ + string sFunc = "GetLocalVariableCount"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +struct NWNX_Object_LocalVariable NWNX_Object_GetLocalVariable(object obj, int index) +{ + string sFunc = "GetLocalVariable"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, index); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); + + struct NWNX_Object_LocalVariable var; + var.key = NWNX_GetReturnValueString(NWNX_Object, sFunc); + var.type = NWNX_GetReturnValueInt(NWNX_Object, sFunc); + return var; +} + +object NWNX_Object_StringToObject(string id) +{ + WriteTimestampedLogEntry("WARNING: NWNX_Object_StringToObject() is deprecated, please use the basegame's StringToObject()"); + + return StringToObject(id); +} + +void NWNX_Object_SetPosition(object oObject, vector vPosition, int bUpdateSubareas = TRUE) +{ + string sFunc = "SetPosition"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bUpdateSubareas); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.x); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.y); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.z); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetCurrentHitPoints(object creature) +{ + string sFunc = "GetCurrentHitPoints"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, creature); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_SetCurrentHitPoints(object creature, int hp) +{ + string sFunc = "SetCurrentHitPoints"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, hp); + NWNX_PushArgumentObject(NWNX_Object, sFunc, creature); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_SetMaxHitPoints(object creature, int hp) +{ + string sFunc = "SetMaxHitPoints"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, hp); + NWNX_PushArgumentObject(NWNX_Object, sFunc, creature); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +string NWNX_Object_Serialize(object obj) +{ + string sFunc = "Serialize"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + return NWNX_GetReturnValueString(NWNX_Object, sFunc); +} + +object NWNX_Object_Deserialize(string serialized) +{ + string sFunc = "Deserialize"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, serialized); + + NWNX_CallFunction(NWNX_Object, sFunc); + return NWNX_GetReturnValueObject(NWNX_Object, sFunc); +} + +string NWNX_Object_GetDialogResref(object obj) +{ + string sFunc = "GetDialogResref"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + return NWNX_GetReturnValueString(NWNX_Object, sFunc); +} + +void NWNX_Object_SetDialogResref(object obj, string dialog) +{ + string sFunc = "SetDialogResref"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, dialog); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_SetAppearance(object oPlaceable, int nAppearance) +{ + string sFunc = "SetAppearance"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, nAppearance); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oPlaceable); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetAppearance(object oPlaceable) +{ + string sFunc = "GetAppearance"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oPlaceable); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_GetHasVisualEffect(object obj, int nVFX) +{ + string sFunc = "GetHasVisualEffect"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, nVFX); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_CheckFit(object obj, int baseitem) +{ + string sFunc = "CheckFit"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, baseitem); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_GetDamageImmunity(object obj, int damageType) +{ + string sFunc = "GetDamageImmunity"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, damageType); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_AddToArea(object obj, object area, vector pos) +{ + string sFunc = "AddToArea"; + + NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.z); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.y); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.x); + NWNX_PushArgumentObject(NWNX_Object, sFunc, area); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetPlaceableIsStatic(object obj) +{ + string sFunc = "GetPlaceableIsStatic"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_SetPlaceableIsStatic(object obj, int isStatic) +{ + string sFunc = "SetPlaceableIsStatic"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, isStatic); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetAutoRemoveKey(object obj) +{ + string sFunc = "GetAutoRemoveKey"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_SetAutoRemoveKey(object obj, int bRemoveKey) +{ + string sFunc = "SetAutoRemoveKey"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bRemoveKey); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +string NWNX_Object_GetTriggerGeometry(object oTrigger) +{ + string sFunc = "GetTriggerGeometry"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oTrigger); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueString(NWNX_Object, sFunc); +} + +void NWNX_Object_SetTriggerGeometry(object oTrigger, string sGeometry) +{ + string sFunc = "SetTriggerGeometry"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sGeometry); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oTrigger); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_AddIconEffect(object obj, int nIcon, float fDuration=0.0) +{ + string sFunc = "AddIconEffect"; + + NWNX_PushArgumentFloat(NWNX_Object, sFunc, fDuration); + NWNX_PushArgumentInt(NWNX_Object, sFunc, nIcon); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_RemoveIconEffect(object obj, int nIcon) +{ + string sFunc = "RemoveIconEffect"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, nIcon); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_Export(string sFileName, object oObject) +{ + string sFunc = "Export"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_PushArgumentString(NWNX_Object, sFunc, sFileName); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetInt(object oObject, string sVarName) +{ + string sFunc = "GetInt"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_SetInt(object oObject, string sVarName, int nValue, int bPersist) +{ + string sFunc = "SetInt"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Object, sFunc, nValue); + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_DeleteInt(object oObject, string sVarName) +{ + string sFunc = "DeleteInt"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +string NWNX_Object_GetString(object oObject, string sVarName) +{ + string sFunc = "GetString"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueString(NWNX_Object, sFunc); +} + +void NWNX_Object_SetString(object oObject, string sVarName, string sValue, int bPersist) +{ + string sFunc = "SetString"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bPersist); + NWNX_PushArgumentString(NWNX_Object, sFunc, sValue); + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_DeleteString(object oObject, string sVarName) +{ + string sFunc = "DeleteString"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +float NWNX_Object_GetFloat(object oObject, string sVarName) +{ + string sFunc = "GetFloat"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueFloat(NWNX_Object, sFunc); +} + +void NWNX_Object_SetFloat(object oObject, string sVarName, float fValue, int bPersist) +{ + string sFunc = "SetFloat"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bPersist); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, fValue); + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_DeleteFloat(object oObject, string sVarName) +{ + string sFunc = "DeleteFloat"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sVarName); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_DeleteVarRegex(object oObject, string sRegex) +{ + string sFunc = "DeleteVarRegex"; + + NWNX_PushArgumentString(NWNX_Object, sFunc, sRegex); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetPositionIsInTrigger(object oTrigger, vector vPosition) +{ + string sFunc = "GetPositionIsInTrigger"; + + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.z); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.y); + NWNX_PushArgumentFloat(NWNX_Object, sFunc, vPosition.x); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oTrigger); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_GetInternalObjectType(object oObject) +{ + string sFunc = "GetInternalObjectType"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_AcquireItem(object oObject, object oItem) +{ + string sFunc = "AcquireItem"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oItem); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +void NWNX_Object_SetFacing(object oObject, float fDirection) +{ + string sFunc = "SetFacing"; + + NWNX_PushArgumentFloat(NWNX_Object, sFunc, fDirection); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +void NWNX_Object_ClearSpellEffectsOnOthers(object oObject) +{ + string sFunc = "ClearSpellEffectsOnOthers"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); +} + +string NWNX_Object_PeekUUID(object oObject) +{ + string sFunc = "PeekUUID"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueString(NWNX_Object, sFunc); +} + +int NWNX_Object_GetDoorHasVisibleModel(object oDoor) +{ + string sFunc = "GetDoorHasVisibleModel"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oDoor); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_GetIsDestroyable(object oObject) +{ + string sFunc = "GetIsDestroyable"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} + +int NWNX_Object_DoSpellImmunity(object oDefender, object oCaster) +{ + string sFunc = "DoSpellImmunity"; + NWNX_PushArgumentObject(NWNX_Object, sFunc, oCaster); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oDefender); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object,sFunc); +} + +int NWNX_Object_DoSpellLevelAbsorption(object oDefender, object oCaster) +{ + string sFunc = "DoSpellLevelAbsorption"; + NWNX_PushArgumentObject(NWNX_Object, sFunc, oCaster); + NWNX_PushArgumentObject(NWNX_Object, sFunc, oDefender); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object,sFunc); +} + +void NWNX_Object_SetHasInventory(object obj, int bHasInventory) +{ + string sFunc = "SetHasInventory"; + + NWNX_PushArgumentInt(NWNX_Object, sFunc, bHasInventory); + NWNX_PushArgumentObject(NWNX_Object, sFunc, obj); + + NWNX_CallFunction(NWNX_Object, sFunc); +} + +int NWNX_Object_GetCurrentAnimation(object oObject) +{ + string sFunc = "GetCurrentAnimation"; + + NWNX_PushArgumentObject(NWNX_Object, sFunc, oObject); + NWNX_CallFunction(NWNX_Object, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Object, sFunc); +} diff --git a/nwnds_module/nwnx_player.nss b/nwnds_module/nwnx_player.nss new file mode 100644 index 000000000..60c4a1c1a --- /dev/null +++ b/nwnds_module/nwnx_player.nss @@ -0,0 +1,963 @@ +/// @addtogroup player +/// @brief Functions exposing additional player properties. +/// @{ +/// @file nwnx_player.nss +#include "nwnx" + +const string NWNX_Player = "NWNX_Player"; ///< @private + +/// @brief A quickbar slot. +struct NWNX_Player_QuickBarSlot +{ + object oItem; ///< @todo Describe + object oSecondaryItem; ///< @todo Describe + int nObjectType; ///< @todo Describe + int nMultiClass; ///< @todo Describe + string sResRef; ///< @todo Describe + string sCommandLabel; ///< @todo Describe + string sCommandLine; ///< @todo Describe + string sToolTip; ///< @todo Describe + int nINTParam1; ///< @todo Describe + int nMetaType; ///< @todo Describe + int nDomainLevel; ///< @todo Describe + int nAssociateType; ///< @todo Describe + object oAssociate; ///< @todo Describe +}; + +/// @brief A journal entry. +struct NWNX_Player_JournalEntry +{ + string sName;///< @todo Describe + string sText;///< @todo Describe + string sTag;///< @todo Describe + int nState;///< @todo Describe + int nPriority;///< @todo Describe + int nQuestCompleted;///< @todo Describe + int nQuestDisplayed;///< @todo Describe + int nUpdated;///< @todo Describe + int nCalendarDay;///< @todo Describe + int nTimeOfDay;///< @todo Describe +}; + + +/// @name Timing Bar Types +/// @anchor timing_bar_types +/// +/// The various types of timing bars. +/// @{ +const int NWNX_PLAYER_TIMING_BAR_TRAP_FLAG = 1; +const int NWNX_PLAYER_TIMING_BAR_TRAP_RECOVER = 2; +const int NWNX_PLAYER_TIMING_BAR_TRAP_DISARM = 3; +const int NWNX_PLAYER_TIMING_BAR_TRAP_EXAMINE = 4; +const int NWNX_PLAYER_TIMING_BAR_TRAP_SET = 5; +const int NWNX_PLAYER_TIMING_BAR_REST = 6; +const int NWNX_PLAYER_TIMING_BAR_UNLOCK = 7; +const int NWNX_PLAYER_TIMING_BAR_LOCK = 8; +const int NWNX_PLAYER_TIMING_BAR_CUSTOM = 10; +/// @} + +/// @name Platform IDs +/// @anchor platform_ids +/// @{ +const int NWNX_PLAYER_PLATFORM_INVALID = 0; +const int NWNX_PLAYER_PLATFORM_WINDOWS_X86 = 1; +const int NWNX_PLAYER_PLATFORM_WINDOWS_X64 = 2; +const int NWNX_PLAYER_PLATFORM_LINUX_X86 = 10; +const int NWNX_PLAYER_PLATFORM_LINUX_X64 = 11; +const int NWNX_PLAYER_PLATFORM_LINUX_ARM32 = 12; +const int NWNX_PLAYER_PLATFORM_LINUX_ARM64 = 13; +const int NWNX_PLAYER_PLATFORM_MAC_X86 = 20; +const int NWNX_PLAYER_PLATFORM_MAC_X64 = 21; +const int NWNX_PLAYER_PLATFORM_IOS = 30; +const int NWNX_PLAYER_PLATFORM_ANDROID_ARM32 = 40; +const int NWNX_PLAYER_PLATFORM_ANDROID_ARM64 = 41; +const int NWNX_PLAYER_PLATFORM_ANDROID_X64 = 42; +const int NWNX_PLAYER_PLATFORM_NINTENDO_SWITCH = 50; +const int NWNX_PLAYER_PLATFORM_MICROSOFT_XBOXONE = 60; +const int NWNX_PLAYER_PLATFORM_SONY_PS4 = 70; +/// @} + +/// @brief Force display placeable examine window for player +/// @note If used on a placeable in a different area than the player, the portait will not be shown. +/// @param player The player object. +/// @param placeable The placeable object. +void NWNX_Player_ForcePlaceableExamineWindow(object player, object placeable); + +/// @brief Force opens the target object's inventory for the player. +/// @note +/// * If the placeable is in a different area than the player, the portrait will not be shown +/// * The placeable's open/close animations will be played +/// * Clicking the 'close' button will cause the player to walk to the placeable If the placeable is in a +/// different area, the player will just walk to the edge of the current area and stop. +/// This action can be cancelled manually. +/// * Walking will close the placeable automatically. +/// @param player The player object. +/// @param placeable The placeable object. +void NWNX_Player_ForcePlaceableInventoryWindow(object player, object placeable); + +/// @brief Starts displaying a timing bar. +/// @param player The player object. +/// @param seconds The length of time the timing bar will complete. +/// @param script The script to run at the bar's completion. +/// @param type The @ref timing_bar_types "Timing Bar Type" +/// @remark Only one timing bar can be ran at the same time. +void NWNX_Player_StartGuiTimingBar(object player, float seconds, string script = "", int type = NWNX_PLAYER_TIMING_BAR_CUSTOM); + +/// @brief Stop displaying a timing bar. +/// @param player The player object. +/// @param script The script to run when stopped. +void NWNX_Player_StopGuiTimingBar(object player, string script = ""); + +/// @brief Sets whether the player should always walk when given movement commands. +/// @param player The player object. +/// @param bWalk TRUE to set the player to always walk. +/// @remark Clicking on the ground or using WASD will trigger walking instead of running. +void NWNX_Player_SetAlwaysWalk(object player, int bWalk=TRUE); + +/// @brief Gets the player's quickbar slot info +/// @param player The player object. +/// @param slot Slot ID 0-35 +/// @return An NWNX_Player_QuickBarSlot struct. +struct NWNX_Player_QuickBarSlot NWNX_Player_GetQuickBarSlot(object player, int slot); + +/// @brief Sets the player's quickbar slot info +/// @param player The player object. +/// @param slot Slot ID 0-35 +/// @param qbs An NWNX_Player_QuickBarSlot struct. +void NWNX_Player_SetQuickBarSlot(object player, int slot, struct NWNX_Player_QuickBarSlot qbs); + +/// @brief Get the name of the .bic file associated with the player's character. +/// @param player The player object. +/// @return The filename for this player's bic. (Not including the ".bic") +string NWNX_Player_GetBicFileName(object player); + +/// @brief Plays the VFX at the target position in current area for the given player only +/// @param player The player object. +/// @param effectId The effect id. +/// @param position The position to play the visual effect. +void NWNX_Player_ShowVisualEffect(object player, int effectId, vector position); + +/// @brief Changes the daytime music track for the given player only +/// @param player The player object. +/// @param track The track id to play. +void NWNX_Player_MusicBackgroundChangeDay(object player, int track); + +/// @brief Changes the nighttime music track for the given player only +/// @param player The player object. +/// @param track The track id to play. +void NWNX_Player_MusicBackgroundChangeNight(object player, int track); + +/// @brief Starts the background music for the given player only +/// @param player The player object. +void NWNX_Player_MusicBackgroundStart(object player); + +/// @brief Stops the background music for the given player only +/// @param player The player object. +void NWNX_Player_MusicBackgroundStop(object player); + +/// @brief Changes the battle music track for the given player only +/// @param player The player object. +/// @param track The track id to play. +void NWNX_Player_MusicBattleChange(object player, int track); + +/// @brief Starts the battle music for the given player only +/// @param player The player object. +void NWNX_Player_MusicBattleStart(object player); + +/// @brief Stops the battle music for the given player only +/// @param player The player object. +void NWNX_Player_MusicBattleStop(object player); + +/// @brief Play a sound at the location of target for the given player only +/// @param player The player object. +/// @param sound The sound resref. +/// @param target The target object for the sound to originate. If target OBJECT_INVALID the sound +/// will play at the location of the player. +void NWNX_Player_PlaySound(object player, string sound, object target = OBJECT_INVALID); + +/// @brief Toggle a placeable's usable flag for the given player only +/// @param player The player object. +/// @param placeable The placeable object. +/// @param usable TRUE for usable. +void NWNX_Player_SetPlaceableUsable(object player, object placeable, int usable); + +/// @brief Override player's rest duration +/// @param player The player object. +/// @param duration The duration of rest in milliseconds, 1000 = 1 second. Minimum duration of 10ms. -1 clears the override. +void NWNX_Player_SetRestDuration(object player, int duration); + +/// @brief Apply visualeffect to target that only player can see +/// @param player The player object. +/// @param target The target object to play the effect upon. +/// @param visualeffect The visual effect id. +/// @note Only works with instant effects: VFX_COM_*, VFX_FNF_*, VFX_IMP_* +void NWNX_Player_ApplyInstantVisualEffectToObject(object player, object target, int visualeffect); + +/// @brief Refreshes the players character sheet +/// @param player The player object. +/// @note You may need to use DelayCommand if you're manipulating values +/// through nwnx and forcing a UI refresh, 0.5s seemed to be fine +void NWNX_Player_UpdateCharacterSheet(object player); + +/// @brief Allows player to open target's inventory +/// @param player The player object. +/// @param target The target object, must be a creature or another player. +/// @param open TRUE to open. +/// @remark Only works if player and target are in the same area. +void NWNX_Player_OpenInventory(object player, object target, int open = TRUE); + +/// @brief Get player's area exploration state +/// @param player The player object. +/// @param area The area object. +/// @return A string representation of the tiles explored for that area. +string NWNX_Player_GetAreaExplorationState(object player, object area); + +/// @brief Set player's area exploration state. +/// @param player The player object. +/// @param area The area object. +/// @param str An encoded string obtained with NWNX_Player_GetAreaExplorationState() +void NWNX_Player_SetAreaExplorationState(object player, object area, string str); + +/// @brief Override player's rest animation. +/// @param oPlayer The player object. +/// @param nAnimation The NWNX animation id. This does not take ANIMATION_LOOPING_* or +/// ANIMATION_FIREFORGET_* constants. Instead use NWNX_Consts_TranslateNWScriptAnimation() to get +/// the NWNX equivalent. -1 to clear the override. +void NWNX_Player_SetRestAnimation(object oPlayer, int nAnimation); + +/// @brief Override a visual transform on the given object that only player will see. +/// @param oPlayer The player object. +/// @param oObject The target object. Can be any valid Creature, Placeable, Item or Door. +/// @param nTransform One of OBJECT_VISUAL_TRANSFORM_* or -1 to remove the override. +/// @param fValue Depends on the transformation to apply. +void NWNX_Player_SetObjectVisualTransformOverride(object oPlayer, object oObject, int nTransform, float fValue); + +/// @brief Apply a looping visualeffect to a target that only player can see +/// @param player The player object. +/// @param target The target object. +/// @param visualeffect A VFX_DUR_*. Calling again will remove an applied effect. -1 to remove all effects +/// @note Only really works with looping effects: VFX_DUR_*. Other types *kind* of work, they'll play when +/// reentering the area and the object is in view or when they come back in view range. +void NWNX_Player_ApplyLoopingVisualEffectToObject(object player, object target, int visualeffect); + +/// @brief Override the name of placeable for player only +/// @param player The player object. +/// @param placeable The placeable object. +/// @param name The name for the placeable for this player, "" to clear the override. +void NWNX_Player_SetPlaceableNameOverride(object player, object placeable, string name); + +/// @brief Gets whether a quest has been completed by a player +/// @param player The player object. +/// @param sQuestName The name identifier of the quest from the Journal Editor. +/// @return TRUE if the quest has been completed. -1 if the player does not have the journal entry. +int NWNX_Player_GetQuestCompleted(object player, string sQuestName); + +/// @brief Place waypoints on module load representing where a PC should start +/// +/// This will require storing the PC's cd key or community name (depending on how you store in your vault) +/// and bic_filename along with routinely updating their location in some persistent method like OnRest, +/// OnAreaEnter and OnClentExit. +/// +/// @param sCDKeyOrCommunityName The Public CD Key or Community Name of the player, this will depend on your vault type. +/// @param sBicFileName The filename for the character. Retrieved with NWNX_Player_GetBicFileName(). +/// @param oWP The waypoint object to place where the PC should start. +/// @param bFirstConnectOnly Set to FALSE if you would like the PC to go to this location every time they login instead +/// of just every server restart. +void NWNX_Player_SetPersistentLocation(string sCDKeyOrCommunityName, string sBicFileName, object oWP, int bFirstConnectOnly = TRUE); + +/// @brief Force an item name to be updated. +/// @note This is a workaround for bug that occurs when updating item names in open containers. +/// @param oPlayer The player object. +/// @param oItem The item object. +void NWNX_Player_UpdateItemName(object oPlayer, object oItem); + +/// @brief Possesses a creature by temporarily making them a familiar +/// @details This command allows a PC to possess an NPC by temporarily adding them as a familiar. It will work +/// if the player already has an existing familiar. The creatures must be in the same area. Unpossession can be +/// done with the regular @nwn{UnpossessFamiliar} commands. +/// @note The possessed creature will send automap data back to the possessor. +/// If you wish to prevent this you may wish to use NWNX_Player_GetAreaExplorationState() and +/// NWNX_Player_SetAreaExplorationState() before and after the possession. +/// @note The possessing creature will be left wherever they were when beginning the possession. You may wish +/// to use @nwn{EffectCutsceneImmobilize} and @nwn{EffectCutsceneGhost} to hide them. +/// @param oPossessor The possessor player object. +/// @param oPossessed The possessed creature object. Only works on NPCs. +/// @param bMindImmune If FALSE will remove the mind immunity effect on the possessor. +/// @param bCreateDefaultQB If TRUE will populate the quick bar with default buttons. +/// @return TRUE if possession succeeded. +int NWNX_Player_PossessCreature(object oPossessor, object oPossessed, int bMindImmune = TRUE, int bCreateDefaultQB = FALSE); + +/// @brief Returns the platform ID of the given player (NWNX_PLAYER_PLATFORM_*) +/// @param oPlayer The player object. +int NWNX_Player_GetPlatformId(object oPlayer); + +/// @brief Returns the game language of the given player (uses NWNX_DIALOG_LANGUAGE_*) +/// @details This function returns the ID of the game language displayed to the player. +/// Uses the same constants as nwnx_dialog. +/// @param oPlayer The player object. +int NWNX_Player_GetLanguage(object oPlayer); + +/// @brief Override sOldResName with sNewResName of nResType for oPlayer. +/// @warning If sNewResName does not exist on oPlayer's client it will crash their game. +/// @param oPlayer The player object. +/// @param nResType The res type, see nwnx_util.nss for constants. +/// @param sOldResName The old res name, 16 characters or less. +/// @param sNewResName The new res name or "" to clear a previous override, 16 characters or less. +void NWNX_Player_SetResManOverride(object oPlayer, int nResType, string sOldResName, string sNewResName); + +/// @brief Set nCustomTokenNumber to sTokenValue for oPlayer only. +/// @note The basegame SetCustomToken() will override any personal tokens. +/// @param oPlayer The player object. +/// @param nCustomTokenNumber The token number. +/// @param sTokenValue The token text. +void NWNX_Player_SetCustomToken(object oPlayer, int nCustomTokenNumber, string sTokenValue); + +/// @brief Override the name of creature for player only +/// @param oPlayer The player object. +/// @param oCreature The creature object. +/// @param sName The name for the creature for this player, "" to clear the override. +void NWNX_Player_SetCreatureNameOverride(object oPlayer, object oCreature, string sName); + +/// @brief Display floaty text above oCreature for oPlayer only. +/// @note This will also display the floaty text above creatures that are not part of oPlayer's faction. +/// @param oPlayer The player to display the text to. +/// @param oCreature The creature to display the text above. +/// @param sText The text to display. +void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText); + +/// @brief Toggle oPlayer's PlayerDM status. +/// @note This function does nothing for actual DMClient DMs or players with a client version < 8193.14 +/// @param oPlayer The player. +/// @param bIsDM TRUE to toggle dm mode on, FALSE for off. +void NWNX_Player_ToggleDM(object oPlayer, int bIsDM); + +/// @brief Override the mouse cursor of oObject for oPlayer only +/// @param oPlayer The player object. +/// @param oObject The object. +/// @param nCursor The cursor, one of MOUSECURSOR_*. -1 to clear the override. +void NWNX_Player_SetObjectMouseCursorOverride(object oPlayer, object oObject, int nCursor); + +/// @brief Override the hilite color of oObject for oPlayer only +/// @param oPlayer The player object. +/// @param oObject The object. +/// @param nColor The color in 0xRRGGBB format, -1 to clear the override. +void NWNX_Player_SetObjectHiliteColorOverride(object oPlayer, object oObject, int nColor); + +/// @brief Remove effects with sEffectTag from oPlayer's TURD +/// @note This function should be called in the NWNX_ON_CLIENT_DISCONNECT_AFTER event, OnClientLeave is too early for the TURD to exist. +/// @param oPlayer The player object. +/// @param sEffectTag The effect tag. +void NWNX_Player_RemoveEffectFromTURD(object oPlayer, string sEffectTag); + +/// @brief Set the location oPlayer will spawn when logging in to the server. +/// @note This function is best called in the NWNX_ON_ELC_VALIDATE_CHARACTER_BEFORE event, OnClientEnter will be too late. +/// @param oPlayer The player object. +/// @param locSpawn The location. +void NWNX_Player_SetSpawnLocation(object oPlayer, location locSpawn); + +/// @brief Resends palettes to a DM. +/// @param oPlayer - the DM to send them to. +void NWNX_Player_SendDMAllCreatorLists(object oPlayer); + +/// @brief Give a custom journal entry to oPlayer. +/// @warning Custom entries are wiped on client enter - they must be reapplied. +/// @param oPlayer The player object. +/// @param journalEntry The journal entry in the form of a struct. +/// @param nSilentUpdate 0 = Notify player via sound effects and feedback message, 1 = Suppress sound effects and feedback message +/// @return a positive number to indicate the new amount of journal entries on the player. +/// @note In contrast to conventional nwn journal entries - this method will overwrite entries with the same tag, so the index / count of entries +/// will only increase if you add new entries with unique tags +int NWNX_Player_AddCustomJournalEntry(object oPlayer, struct NWNX_Player_JournalEntry journalEntry, int nSilentUpdate = 0); + +/// @brief Returns a struct containing a journal entry that can then be modified. +/// @param oPlayer The player object. +/// @param questTag The quest tag you wish to get the journal entry for. +/// @return a struct containing the journal entry data. +/// @note This method will return -1 for the Updated field in the event that no matching journal entry was found, +/// only the last matching quest tag will be returned. Eg: If you add 3 journal updates to a player, only the 3rd one will be returned as +/// that is the active one that the player currently sees. +struct NWNX_Player_JournalEntry NWNX_Player_GetJournalEntry(object oPlayer, string questTag); + +/// @brief Closes any store oPlayer may have open. +/// @param oPlayer The player object. +void NWNX_Player_CloseStore(object oPlayer); + +/// @} + +void NWNX_Player_ForcePlaceableExamineWindow(object player, object placeable) +{ + string sFunc = "ForcePlaceableExamineWindow"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, placeable); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_ForcePlaceableInventoryWindow(object player, object placeable) +{ + string sFunc = "ForcePlaceableInventoryWindow"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, placeable); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_INTERNAL_StopGuiTimingBar(object player, string script = "", int id = -1) ///< @private +{ + int activeId = GetLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ACTIVE"); + // Either the timing event was never started, or it already finished. + if (activeId == 0) + return; + + // If id != -1, we ended up here through DelayCommand. Make sure it's for the right ID + if (id != -1 && id != activeId) + return; + + DeleteLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ACTIVE"); + + string sFunc = "StopGuiTimingBar"; + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + NWNX_CallFunction(NWNX_Player, sFunc); + + if(script != "") + { + ExecuteScript(script, player); + } +} + +void NWNX_Player_StartGuiTimingBar(object player, float seconds, string script = "", int type = NWNX_PLAYER_TIMING_BAR_CUSTOM) +{ + if (GetLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ACTIVE")) + return; + + string sFunc = "StartGuiTimingBar"; + NWNX_PushArgumentInt(NWNX_Player, sFunc, type); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, seconds); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); + + int id = GetLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ID") + 1; + SetLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ACTIVE", id); + SetLocalInt(player, "NWNX_PLAYER_GUI_TIMING_ID", id); + + DelayCommand(seconds, NWNX_Player_INTERNAL_StopGuiTimingBar(player, script, id)); +} + +void NWNX_Player_StopGuiTimingBar(object player, string script = "") +{ + NWNX_Player_INTERNAL_StopGuiTimingBar(player, script, -1); +} + +void NWNX_Player_SetAlwaysWalk(object player, int bWalk=TRUE) +{ + string sFunc = "SetAlwaysWalk"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, bWalk); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_GetQuickBarSlot(object player, int slot) +{ + string sFunc = "GetQuickBarSlot"; + struct NWNX_Player_QuickBarSlot qbs; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, slot); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + NWNX_CallFunction(NWNX_Player, sFunc); + + qbs.oAssociate = NWNX_GetReturnValueObject(NWNX_Player, sFunc); + qbs.nAssociateType = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.nDomainLevel = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.nMetaType = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.nINTParam1 = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.sToolTip = NWNX_GetReturnValueString(NWNX_Player, sFunc); + qbs.sCommandLine = NWNX_GetReturnValueString(NWNX_Player, sFunc); + qbs.sCommandLabel = NWNX_GetReturnValueString(NWNX_Player, sFunc); + qbs.sResRef = NWNX_GetReturnValueString(NWNX_Player, sFunc); + qbs.nMultiClass = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.nObjectType = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + qbs.oSecondaryItem = NWNX_GetReturnValueObject(NWNX_Player, sFunc); + qbs.oItem = NWNX_GetReturnValueObject(NWNX_Player, sFunc); + + return qbs; +} + +void NWNX_Player_SetQuickBarSlot(object player, int slot, struct NWNX_Player_QuickBarSlot qbs) +{ + string sFunc = "SetQuickBarSlot"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, qbs.oItem); + NWNX_PushArgumentObject(NWNX_Player, sFunc, qbs.oSecondaryItem); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nObjectType); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nMultiClass); + NWNX_PushArgumentString(NWNX_Player, sFunc, qbs.sResRef); + NWNX_PushArgumentString(NWNX_Player, sFunc, qbs.sCommandLabel); + NWNX_PushArgumentString(NWNX_Player, sFunc, qbs.sCommandLine); + NWNX_PushArgumentString(NWNX_Player, sFunc, qbs.sToolTip); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nINTParam1); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nMetaType); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nDomainLevel); + NWNX_PushArgumentInt(NWNX_Player, sFunc, qbs.nAssociateType); + NWNX_PushArgumentObject(NWNX_Player, sFunc, qbs.oAssociate); + + NWNX_PushArgumentInt(NWNX_Player, sFunc, slot); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + NWNX_CallFunction(NWNX_Player, sFunc); +} + +string NWNX_Player_GetBicFileName(object player) +{ + string sFunc = "GetBicFileName"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueString(NWNX_Player, sFunc); +} + +void NWNX_Player_ShowVisualEffect(object player, int effectId, vector position) +{ + string sFunc = "ShowVisualEffect"; + + NWNX_PushArgumentFloat(NWNX_Player, sFunc, position.x); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, position.y); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, position.z); + NWNX_PushArgumentInt(NWNX_Player, sFunc, effectId); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBackgroundChangeDay(object player, int track) +{ + string sFunc = "ChangeBackgroundMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, track); + NWNX_PushArgumentInt(NWNX_Player, sFunc, TRUE); // bool day = TRUE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBackgroundChangeNight(object player, int track) +{ + string sFunc = "ChangeBackgroundMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, track); + NWNX_PushArgumentInt(NWNX_Player, sFunc, FALSE); // bool day = FALSE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBackgroundStart(object player) +{ + string sFunc = "PlayBackgroundMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, TRUE); // bool play = TRUE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBackgroundStop(object player) +{ + string sFunc = "PlayBackgroundMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, FALSE); // bool play = FALSE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBattleChange(object player, int track) +{ + string sFunc = "ChangeBattleMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, track); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBattleStart(object player) +{ + string sFunc = "PlayBattleMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, TRUE); // bool play = TRUE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_MusicBattleStop(object player) +{ + string sFunc = "PlayBattleMusic"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, FALSE); // bool play = FALSE + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_PlaySound(object player, string sound, object target = OBJECT_INVALID) +{ + string sFunc = "PlaySound"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, target); + NWNX_PushArgumentString(NWNX_Player, sFunc, sound); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetPlaceableUsable(object player, object placeable, int usable) +{ + string sFunc = "SetPlaceableUsable"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, usable); + NWNX_PushArgumentObject(NWNX_Player, sFunc, placeable); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetRestDuration(object player, int duration) +{ + string sFunc = "SetRestDuration"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, duration); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_ApplyInstantVisualEffectToObject(object player, object target, int visualeffect) +{ + string sFunc = "ApplyInstantVisualEffectToObject"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, visualeffect); + NWNX_PushArgumentObject(NWNX_Player, sFunc, target); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_UpdateCharacterSheet(object player) +{ + string sFunc = "UpdateCharacterSheet"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_OpenInventory(object player, object target, int open = TRUE) +{ + string sFunc = "OpenInventory"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, open); + NWNX_PushArgumentObject(NWNX_Player, sFunc, target); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +string NWNX_Player_GetAreaExplorationState(object player, object area) +{ + string sFunc = "GetAreaExplorationState"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, area); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueString(NWNX_Player, sFunc); +} + +void NWNX_Player_SetAreaExplorationState(object player, object area, string str) +{ + string sFunc = "SetAreaExplorationState"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, str); + NWNX_PushArgumentObject(NWNX_Player, sFunc, area); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetRestAnimation(object oPlayer, int nAnimation) +{ + string sFunc = "SetRestAnimation"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, nAnimation); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetObjectVisualTransformOverride(object oPlayer, object oObject, int nTransform, float fValue) +{ + string sFunc = "SetObjectVisualTransformOverride"; + + NWNX_PushArgumentFloat(NWNX_Player, sFunc, fValue); + NWNX_PushArgumentInt(NWNX_Player, sFunc, nTransform); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oObject); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_ApplyLoopingVisualEffectToObject(object player, object target, int visualeffect) +{ + string sFunc = "ApplyLoopingVisualEffectToObject"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, visualeffect); + NWNX_PushArgumentObject(NWNX_Player, sFunc, target); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetPlaceableNameOverride(object player, object placeable, string name) +{ + string sFunc = "SetPlaceableNameOverride"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, name); + NWNX_PushArgumentObject(NWNX_Player, sFunc, placeable); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +int NWNX_Player_GetQuestCompleted(object player, string sQuestName) +{ + string sFunc = "GetQuestCompleted"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sQuestName); + NWNX_PushArgumentObject(NWNX_Player, sFunc, player); + + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueInt(NWNX_Player, sFunc); +} + +void NWNX_Player_SetPersistentLocation(string sCDKeyOrCommunityName, string sBicFileName, object oWP, int bFirstConnectOnly = TRUE) +{ + string sFunc = "SetPersistentLocation"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, bFirstConnectOnly); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oWP); + NWNX_PushArgumentString(NWNX_Player, sFunc, sBicFileName); + NWNX_PushArgumentString(NWNX_Player, sFunc, sCDKeyOrCommunityName); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_UpdateItemName(object oPlayer, object oItem) +{ + string sFunc = "UpdateItemName"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, oItem); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +int NWNX_Player_PossessCreature(object oPossessor, object oPossessed, int bMindImmune = TRUE, int bCreateDefaultQB = FALSE) +{ + string sFunc = "PossessCreature"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, bCreateDefaultQB); + NWNX_PushArgumentInt(NWNX_Player, sFunc, bMindImmune); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPossessed); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPossessor); + + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueInt(NWNX_Player, sFunc); +} + +int NWNX_Player_GetPlatformId(object oPlayer) +{ + string sFunc = "GetPlatformId"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueInt(NWNX_Player, sFunc); +} + +int NWNX_Player_GetLanguage(object oPlayer) +{ + string sFunc = "GetLanguage"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueInt(NWNX_Player, sFunc); +} + +void NWNX_Player_SetResManOverride(object oPlayer, int nResType, string sOldResName, string sNewResName) +{ + string sFunc = "SetResManOverride"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sNewResName); + NWNX_PushArgumentString(NWNX_Player, sFunc, sOldResName); + NWNX_PushArgumentInt(NWNX_Player, sFunc, nResType); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetCustomToken(object oPlayer, int nCustomTokenNumber, string sTokenValue) +{ + string sFunc = "SetCustomToken"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sTokenValue); + NWNX_PushArgumentInt(NWNX_Player, sFunc, nCustomTokenNumber); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetCreatureNameOverride(object oPlayer, object oCreature, string sName) +{ + string sFunc = "SetCreatureNameOverride"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sName); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oCreature); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText) +{ + string sFunc = "FloatingTextStringOnCreature"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sText); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oCreature); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_ToggleDM(object oPlayer, int bIsDM) +{ + string sFunc = "ToggleDM"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, bIsDM); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetObjectMouseCursorOverride(object oPlayer, object oObject, int nCursor) +{ + string sFunc = "SetObjectMouseCursorOverride"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, nCursor); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oObject); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetObjectHiliteColorOverride(object oPlayer, object oObject, int nColor) +{ + string sFunc = "SetObjectHiliteColorOverride"; + + NWNX_PushArgumentInt(NWNX_Player, sFunc, nColor); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oObject); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_RemoveEffectFromTURD(object oPlayer, string sEffectTag) +{ + string sFunc = "RemoveEffectFromTURD"; + + NWNX_PushArgumentString(NWNX_Player, sFunc, sEffectTag); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SetSpawnLocation(object oPlayer, location locSpawn) +{ + string sFunc = "SetSpawnLocation"; + + vector vPosition = GetPositionFromLocation(locSpawn); + + NWNX_PushArgumentFloat(NWNX_Player, sFunc, GetFacingFromLocation(locSpawn)); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, vPosition.z); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, vPosition.y); + NWNX_PushArgumentFloat(NWNX_Player, sFunc, vPosition.x); + NWNX_PushArgumentObject(NWNX_Player, sFunc, GetAreaFromLocation(locSpawn)); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + + NWNX_CallFunction(NWNX_Player, sFunc); +} + +void NWNX_Player_SendDMAllCreatorLists(object oPlayer) +{ + string sFunc = "SendDMAllCreatorLists"; + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Player, sFunc); +} + +int NWNX_Player_AddCustomJournalEntry(object oPlayer, struct NWNX_Player_JournalEntry journalEntry, int nSilentUpdate = 0) +{ + string sFunc = "AddCustomJournalEntry"; + NWNX_PushArgumentInt(NWNX_Player, sFunc, nSilentUpdate); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nTimeOfDay); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nCalendarDay); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nUpdated); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nQuestDisplayed); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nQuestCompleted); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nPriority); + NWNX_PushArgumentInt(NWNX_Player, sFunc, journalEntry.nState); + NWNX_PushArgumentString(NWNX_Player, sFunc, journalEntry.sTag); + NWNX_PushArgumentString(NWNX_Player, sFunc, journalEntry.sText); + NWNX_PushArgumentString(NWNX_Player, sFunc, journalEntry.sName); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Player, sFunc); + return NWNX_GetReturnValueInt(NWNX_Player, sFunc); +} + +struct NWNX_Player_JournalEntry NWNX_Player_GetJournalEntry(object oPlayer, string questTag) +{ + string sFunc = "GetJournalEntry"; + struct NWNX_Player_JournalEntry entry; + + NWNX_PushArgumentString(NWNX_Player, sFunc, questTag); + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Player, sFunc); + + entry.nUpdated = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + if(entry.nUpdated == -1) // -1 set as an indicator to say that the entry was not found + { + return entry; + } + entry.nQuestDisplayed = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.nQuestCompleted = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.nPriority = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.nState = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.nTimeOfDay = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.nCalendarDay = NWNX_GetReturnValueInt(NWNX_Player, sFunc); + entry.sName = NWNX_GetReturnValueString(NWNX_Player, sFunc); + entry.sText = NWNX_GetReturnValueString(NWNX_Player, sFunc); + entry.sTag = questTag; + return entry; +} + +void NWNX_Player_CloseStore(object oPlayer) +{ + string sFunc = "CloseStore"; + + NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Player, sFunc); +} diff --git a/nwnds_module/nwnx_player_qbs.nss b/nwnds_module/nwnx_player_qbs.nss new file mode 100644 index 000000000..0649c97ac --- /dev/null +++ b/nwnds_module/nwnx_player_qbs.nss @@ -0,0 +1,207 @@ +/// @addtogroup player +/// @{ +/// @file nwnx_player_qbs.nss +/// @brief Helper script for quickbar management. +#include "nwnx_player" + +/// @name Quickbar Slot Types +/// @anchor qbs_types +/// @{ +const int NWNX_PLAYER_QBS_TYPE_EMPTY = 0; +const int NWNX_PLAYER_QBS_TYPE_ITEM = 1; +const int NWNX_PLAYER_QBS_TYPE_SPELL = 2; +const int NWNX_PLAYER_QBS_TYPE_SKILL = 3; +const int NWNX_PLAYER_QBS_TYPE_FEAT = 4; +const int NWNX_PLAYER_QBS_TYPE_DIALOG = 6; +const int NWNX_PLAYER_QBS_TYPE_ATTACK = 7; +const int NWNX_PLAYER_QBS_TYPE_EMOTE = 8; +const int NWNX_PLAYER_QBS_TYPE_ITEM_PROPERTY_CASTSPELL = 9; +const int NWNX_PLAYER_QBS_TYPE_MODE_TOGGLE = 10; +const int NWNX_PLAYER_QBS_TYPE_COMMAND = 18; +const int NWNX_PLAYER_QBS_TYPE_POSSESS_FAMILIAR = 38; +const int NWNX_PLAYER_QBS_TYPE_ASSOCIATE_COMMAND = 39; +const int NWNX_PLAYER_QBS_TYPE_EXAMINE = 40; +const int NWNX_PLAYER_QBS_TYPE_BARTER = 41; +const int NWNX_PLAYER_QBS_TYPE_QUICK_CHAT = 42; +const int NWNX_PLAYER_QBS_TYPE_CANCELPOLYMORPH = 43; +const int NWNX_PLAYER_QBS_TYPE_SPELLLIKEABILITY = 44; +/// @} + +/// Create an empty QBS of given type +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Empty(int type = NWNX_PLAYER_QBS_TYPE_EMPTY); +/// Create a QBS for using an item +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseItem(object oItem, int nPropertyID = 0); +/// Create a QBS for equipping an item +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_EquipItem(object oItem, object oSecondaryItem = OBJECT_INVALID); +/// Create a QBS for casting a spell +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_CastSpell(int nSpell, int nClassIndex = 0, int nMetamagic = METAMAGIC_NONE, int nDomainLevel = -1); +/// Create a QBS for using a skill +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseSkill(int nSkill); +/// Create a QBS for using a feat +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseFeat(int nFeat); +/// Create a QBS for starting a dialog +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_StartDialog(); +/// Create a QBS for attacking +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Attack(); +/// Create a QBS for emoting +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Emote(int nEmote); +/// Create a QBS for toggling a mode +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_ToggleMode(int nMode); +/// Create a QBS for examining +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Examine(); +/// Create a QBS for bartering +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Barter(); +/// Create a QBS for quickchat command +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_QuickChat(int nCommand); +/// Create a QBS for examining +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_PossessFamiliar(); +/// Create a QBS for casting a spell +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseSpecialAbility(int nSpell, int nCasterLevel); +/// Create a QBS for running a command +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Command(string sCommandLabel, string sCommandLine); + +/// @} + + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Empty(int type = NWNX_PLAYER_QBS_TYPE_EMPTY) +{ + struct NWNX_Player_QuickBarSlot qbs; + + qbs.nObjectType = type; + + qbs.oItem = OBJECT_INVALID; + qbs.oSecondaryItem = OBJECT_INVALID; + qbs.nMultiClass = 0; + qbs.sResRef = ""; + qbs.sCommandLabel = ""; + qbs.sCommandLine = ""; + qbs.sToolTip = ""; + qbs.nINTParam1 = 0; + qbs.nMetaType = 0; + qbs.nDomainLevel = 0; + qbs.nAssociateType = 0; + qbs.oAssociate = OBJECT_INVALID; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseItem(object oItem, int nPropertyID = 0) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_ITEM); + + qbs.oItem = oItem; + qbs.nINTParam1 = nPropertyID; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_EquipItem(object oItem, object oSecondaryItem = OBJECT_INVALID) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_ITEM); + + qbs.oItem = oItem; + qbs.oSecondaryItem = oSecondaryItem; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_CastSpell(int nSpell, int nClassIndex = 0, int nMetamagic = METAMAGIC_NONE, int nDomainLevel = -1) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_SPELL); + + qbs.nINTParam1 = nSpell; + qbs.nMultiClass = nClassIndex; + qbs.nMetaType = nMetamagic; + qbs.nDomainLevel = nDomainLevel; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseSkill(int nSkill) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_SKILL); + + qbs.nINTParam1 = nSkill; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseFeat(int nFeat) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_FEAT); + + qbs.nINTParam1 = nFeat; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_StartDialog() +{ + return NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_DIALOG); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Attack() +{ + return NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_ATTACK); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Emote(int nEmote) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_EMOTE); + + qbs.nINTParam1 = nEmote; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_ToggleMode(int nMode) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_MODE_TOGGLE); + + qbs.nINTParam1 = nMode; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Examine() +{ + return NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_EXAMINE); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Barter() +{ + return NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_BARTER); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_QuickChat(int nCommand) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_QUICK_CHAT); + + qbs.nINTParam1 = nCommand; + + return qbs; +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_PossessFamiliar() +{ + return NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_POSSESS_FAMILIAR); +} + +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_UseSpecialAbility(int nSpell, int nCasterLevel) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_SPELL); + + qbs.nINTParam1 = nSpell; + qbs.nDomainLevel = nCasterLevel; + + return qbs; +} +struct NWNX_Player_QuickBarSlot NWNX_Player_QBS_Command(string sCommandLabel, string sCommandLine) +{ + struct NWNX_Player_QuickBarSlot qbs = NWNX_Player_QBS_Empty(NWNX_PLAYER_QBS_TYPE_COMMAND); + + qbs.sCommandLabel = sCommandLabel; + qbs.sCommandLine = sCommandLine; + + return qbs; +} diff --git a/nwnds_module/nwnx_profiler.nss b/nwnds_module/nwnx_profiler.nss new file mode 100644 index 000000000..4c7393e84 --- /dev/null +++ b/nwnds_module/nwnx_profiler.nss @@ -0,0 +1,60 @@ +/// @addtogroup profiler Profiler +/// @brief Functions to instrument nwscript code. +/// @remark These functions are for advanced users. +/// @{ +/// @file nwnx_profiler.nss +#include "nwnx" + +const string NWNX_Profiler = "NWNX_Profiler"; ///< @private + +/// @brief Push a timing metric scope - note that every push must be matched by a corresponding pop. +/// +/// A timing metric contains the following information. +/// ```c +/// { +/// metricName: [name], // Mandatory, from user code +/// metricFields: { time, nanoseconds }, // Automatically captured by the push/pop pair +/// metricTags: { [tag0_tag], [tag0_value] } // Optional, from user code, can be used to +/// filter metrics based on some category or, +/// constant e.g. objectType or area +/// } +/// ``` +/// +/// If you don't understand how this works and you wish to use it, you should research +/// the Metrics system (see Metrics.hpp) as well as googling about how InfluxDB stores metrics. +/// +/// @note It's possible to have more than one tag pair per metric, It is just limited +/// to one arbitrarily here. You can edit the prototype to include more and the C++ +/// code will cope with it correctly. +/// @param name The name to use for your metric. +/// @param tag0_tag An optional tag to filter your metrics. +/// @param tag0_value The tag's value for which to filter. +void NWNX_Profiler_PushPerfScope(string name, string tag0_tag = "", string tag0_value = ""); + +/// @brief Pops a timing metric. +/// @remark A metric must already be pushed. +void NWNX_Profiler_PopPerfScope(); + +/// @} + +void NWNX_Profiler_PushPerfScope(string name, string tag0_tag = "", string tag0_value = "") +{ + string sFunc = "PushPerfScope"; + + NWNX_PushArgumentString(NWNX_Profiler, sFunc, name); + + if (tag0_value != "" && tag0_tag != "") + { + NWNX_PushArgumentString(NWNX_Profiler, sFunc, tag0_value); + NWNX_PushArgumentString(NWNX_Profiler, sFunc, tag0_tag); + } + + NWNX_CallFunction(NWNX_Profiler, sFunc); +} + +void NWNX_Profiler_PopPerfScope() +{ + string sFunc = "PopPerfScope"; + + NWNX_CallFunction(NWNX_Profiler, sFunc); +} \ No newline at end of file diff --git a/nwnds_module/nwnx_race.nss b/nwnds_module/nwnx_race.nss new file mode 100644 index 000000000..48360c303 --- /dev/null +++ b/nwnds_module/nwnx_race.nss @@ -0,0 +1,90 @@ +/// @addtogroup race Race +/// @brief Define racial and subrace characteristics. +/// @{ +/// @file nwnx_race.nss +#include "nwnx" + +const string NWNX_Race = "NWNX_Race"; ///< @private + +/// @name Racial Modifiers +/// @anchor racial_modifiers +/// +/// @{ +const int NWNX_RACE_MODIFIER_INVALID = 0; +const int NWNX_RACE_MODIFIER_AB = 1; +const int NWNX_RACE_MODIFIER_ABVSRACE = 2; +const int NWNX_RACE_MODIFIER_AC = 3; +const int NWNX_RACE_MODIFIER_ACVSRACE = 4; +const int NWNX_RACE_MODIFIER_CONCEALMENT = 5; +const int NWNX_RACE_MODIFIER_DMGIMMUNITY = 6; +const int NWNX_RACE_MODIFIER_DMGREDUCTION = 7; +const int NWNX_RACE_MODIFIER_DMGRESIST = 8; +const int NWNX_RACE_MODIFIER_FEAT = 9; +const int NWNX_RACE_MODIFIER_FEATUSAGE = 10; +const int NWNX_RACE_MODIFIER_IMMUNITY = 11; +const int NWNX_RACE_MODIFIER_INITIATIVE = 12; +const int NWNX_RACE_MODIFIER_MOVEMENTSPEED = 13; +const int NWNX_RACE_MODIFIER_RACE = 14; +const int NWNX_RACE_MODIFIER_REGENERATION = 15; +const int NWNX_RACE_MODIFIER_SAVE = 16; +const int NWNX_RACE_MODIFIER_SAVEVSRACE = 17; +const int NWNX_RACE_MODIFIER_SAVEVSTYPE = 18; +const int NWNX_RACE_MODIFIER_SKILL = 19; +const int NWNX_RACE_MODIFIER_SPELLIMMUNITY = 20; +const int NWNX_RACE_MODIFIER_SRCHARGEN = 21; +const int NWNX_RACE_MODIFIER_SRINCLEVEL = 22; +///@} + +/// @brief Sets a racial modifier. +/// @param iRace The RACIALTYPE_ constant or value in racialtypes.2da. +/// @param iMod The @ref racial_modifiers "racial modifier" to set. +/// @param iParam1, iParam2, iParam3 The parameters for this racial modifier. +void NWNX_Race_SetRacialModifier(int iRace, int iMod, int iParam1, int iParam2 = 0xDEADBEEF, int iParam3 = 0xDEADBEEF); + +/// @brief Gets the parent race for a race. +/// @param iRace The race to check for a parent. +/// @return The parent race if applicable, if not it just returns the race passed in. +int NWNX_Race_GetParentRace(int iRace); + +/// @brief Associates the race with its favored enemy feat. +/// @param iRace The race +/// @param iFeat The feat +/// @note If a creature has a race that has a parent race then favored enemy bonuses will work for either race against that creature. +/// For example a creature is a Wild Elf which has a parent race of Elf, an attacker would benefit if they had either Favored Enemy: Elf +/// or Favored Enemy: Wild Elf +void NWNX_Race_SetFavoredEnemyFeat(int iRace, int iFeat); + +/// @} + +void NWNX_Race_SetRacialModifier(int iRace, int iMod, int iParam1, int iParam2 = 0xDEADBEEF, int iParam3 = 0xDEADBEEF) +{ + string sFunc = "SetRacialModifier"; + + NWNX_PushArgumentInt(NWNX_Race, sFunc, iParam3); + NWNX_PushArgumentInt(NWNX_Race, sFunc, iParam2); + NWNX_PushArgumentInt(NWNX_Race, sFunc, iParam1); + NWNX_PushArgumentInt(NWNX_Race, sFunc, iMod); + NWNX_PushArgumentInt(NWNX_Race, sFunc, iRace); + + NWNX_CallFunction(NWNX_Race, sFunc); +} + +int NWNX_Race_GetParentRace(int iRace) +{ + string sFunc = "GetParentRace"; + + NWNX_PushArgumentInt(NWNX_Race, sFunc, iRace); + + NWNX_CallFunction(NWNX_Race, sFunc); + return NWNX_GetReturnValueInt(NWNX_Race, sFunc); +} + +void NWNX_Race_SetFavoredEnemyFeat(int iRace, int iFeat) +{ + string sFunc = "SetFavoredEnemyFeat"; + + NWNX_PushArgumentInt(NWNX_Race, sFunc, iFeat); + NWNX_PushArgumentInt(NWNX_Race, sFunc, iRace); + + NWNX_CallFunction(NWNX_Race, sFunc); +} diff --git a/nwnds_module/nwnx_race_2da.nss b/nwnds_module/nwnx_race_2da.nss new file mode 100644 index 000000000..5b6f8021a --- /dev/null +++ b/nwnds_module/nwnx_race_2da.nss @@ -0,0 +1,70 @@ +/// @ingroup race +/// @file nwnx_race_2da.nss +/// @brief Parse a column in the racialtypes.2da to load the modifiers. +#include "nwnx_race" +#include "nwnx_util" + +/// @ingroup race +/// @brief Translate a modifier type from a string to its constant. +/// @param raceMod The string representation of the constant. +/// @return The constant for the race modifier. +int NWNX_Race_GetModifierConstant(string raceMod); + +/// @ingroup race +/// @brief Loops through racialtypes.2da and checks for the column for racial modifications and sets them. +/// @note Requires NWNX_Util_Get2DARowCount() +/// @param sColumnName The column name in the racialtypes.2da that defines the 2da for the racial mods. +void NWNX_Race_LoadRacialModifiers(string sColumnName = "RacialModsTable"); + +int NWNX_Race_GetModifierConstant(string raceMod) +{ + if (raceMod == "AB") return NWNX_RACE_MODIFIER_AB; + else if (raceMod == "ABVSRACE") return NWNX_RACE_MODIFIER_ABVSRACE; + else if (raceMod == "AC") return NWNX_RACE_MODIFIER_AC; + else if (raceMod == "ACVSRACE") return NWNX_RACE_MODIFIER_ACVSRACE; + else if (raceMod == "CONCEALMENT") return NWNX_RACE_MODIFIER_CONCEALMENT; + else if (raceMod == "DMGIMMUNITY") return NWNX_RACE_MODIFIER_DMGIMMUNITY; + else if (raceMod == "DMGREDUCTION") return NWNX_RACE_MODIFIER_DMGREDUCTION; + else if (raceMod == "DMGRESIST") return NWNX_RACE_MODIFIER_DMGRESIST; + else if (raceMod == "FEAT") return NWNX_RACE_MODIFIER_FEAT; + else if (raceMod == "FEATUSAGE") return NWNX_RACE_MODIFIER_FEATUSAGE; + else if (raceMod == "IMMUNITY") return NWNX_RACE_MODIFIER_IMMUNITY; + else if (raceMod == "INITIATIVE") return NWNX_RACE_MODIFIER_INITIATIVE; + else if (raceMod == "MOVEMENTSPEED") return NWNX_RACE_MODIFIER_MOVEMENTSPEED; + else if (raceMod == "RACE") return NWNX_RACE_MODIFIER_RACE; + else if (raceMod == "REGENERATION") return NWNX_RACE_MODIFIER_REGENERATION; + else if (raceMod == "SAVE") return NWNX_RACE_MODIFIER_SAVE; + else if (raceMod == "SAVEVSRACE") return NWNX_RACE_MODIFIER_SAVEVSRACE; + else if (raceMod == "SAVEVSTYPE") return NWNX_RACE_MODIFIER_SAVEVSTYPE; + else if (raceMod == "SKILL") return NWNX_RACE_MODIFIER_SKILL; + else if (raceMod == "SPELLIMMUNITY") return NWNX_RACE_MODIFIER_SPELLIMMUNITY; + else if (raceMod == "SRCHARGEN") return NWNX_RACE_MODIFIER_SRCHARGEN; + else if (raceMod == "SRINCLEVEL") return NWNX_RACE_MODIFIER_SRINCLEVEL; + return NWNX_RACE_MODIFIER_INVALID; +} + +void NWNX_Race_LoadRacialModifiers(string sColumnName = "RacialModsTable") +{ + int iRaceRows = NWNX_Util_Get2DARowCount("racialtypes"); + int iRace; + for (iRace = 0; iRace < iRaceRows; iRace++) + { + string sRaceModTable = Get2DAString("racialtypes", sColumnName, iRace); + if(sRaceModTable != "") + { + int iRaceModRows = NWNX_Util_Get2DARowCount(sRaceModTable); + int iRaceMod; + for (iRaceMod = 0; iRaceMod < iRaceModRows; iRaceMod++) + { + string sType = Get2DAString(sRaceModTable, "Type", iRaceMod); + string sParam1 = Get2DAString(sRaceModTable, "Param1", iRaceMod); + string sParam2 = Get2DAString(sRaceModTable, "Param2", iRaceMod); + string sParam3 = Get2DAString(sRaceModTable, "Param3", iRaceMod); + int iParam1 = sParam1 == "" ? 0xDEADBEEF : StringToInt(sParam1); + int iParam2 = sParam2 == "" ? 0xDEADBEEF : StringToInt(sParam2); + int iParam3 = sParam3 == "" ? 0xDEADBEEF : StringToInt(sParam3); + NWNX_Race_SetRacialModifier(iRace, NWNX_Race_GetModifierConstant(sType), iParam1, iParam2, iParam3); + } + } + } +} diff --git a/nwnds_module/nwnx_redis.nss b/nwnds_module/nwnx_redis.nss new file mode 100644 index 000000000..56d00967b --- /dev/null +++ b/nwnds_module/nwnx_redis.nss @@ -0,0 +1,5906 @@ +/// @ingroup redis +/// @brief Autogenerated redis commands for NWNX usage. Autogenerated on: 2019-10-01 20:51:53 -0400 +/// @{ +/// @file nwnx_redis.nss +/// @name Redis Commands +#include "nwnx" +#include "nwnx_redis_lib" + + +// Skipping sub-command: BITFIELD/{"command"=>"OVERFLOW", "type"=>"enum", "enum"=>["WRAP", "SAT", "FAIL"], "optional"=>true} - not supported yet. +// Skipping sub-command: CLIENT_KILL/{"command"=>"TYPE", "type"=>"enum", "enum"=>["normal", "master", "slave", "pubsub"], "optional"=>true} - not supported yet. +// Skipping sub-command: CLIENT_LIST/{"command"=>"TYPE", "type"=>"enum", "enum"=>["normal", "master", "replica", "pubsub"], "optional"=>true} - not supported yet. +// Skipping sub-command: SET/{"command"=>"expiration", "type"=>"enum", "enum"=>["EX seconds", "PX milliseconds"], "optional"=>true} - not supported yet. +// Skipping XCLAIM, cannot parse argument: {"name"=>"force", "enum"=>["FORCE"], "optional"=>true} - not supported yet. +// Skipping XCLAIM, cannot parse argument: {"name"=>"justid", "enum"=>["JUSTID"], "optional"=>true} - not supported yet. +/** + * APPEND + * + * Append a value to a key + * + * Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is + * small and the already present value is of any size, since the dynamic string + * library used by Redis will double the free space available on every + * reallocation. + * Annotated return value: integer + */ +int NWNX_Redis_APPEND( + string key, + string value +); + +/** + * AUTH + * + * Authenticate to the server + * Annotated return value: simple-string + */ +int NWNX_Redis_AUTH( + string password +); + +/** + * BGREWRITEAOF + * + * Asynchronously rewrite the append-only file + * Annotated return value: simple-string + */ +int NWNX_Redis_BGREWRITEAOF(); + +/** + * BGSAVE + * + * Asynchronously save the dataset to disk + * Annotated return value: simple-string + */ +int NWNX_Redis_BGSAVE(); + +/** + * BITCOUNT + * + * Count set bits in a string + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int NWNX_Redis_BITCOUNT( + string key, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +); + +/** + * BITFIELD + * + * Perform arbitrary bitfield integer operations on strings + * + * Time complexity: O(1) for each subcommand specified + * Annotated return value: + */ +int NWNX_Redis_BITFIELD( + string key, + // Redis type: type + string get_type = "", + // Redis type: integer + int get_offset = 0, + // Redis type: type + string set_type = "", + // Redis type: integer + int set_offset = 0, + // Redis type: integer + int set_value = 0, + // Redis type: type + string incrby_type = "", + // Redis type: integer + int incrby_offset = 0, + // Redis type: integer + int incrby_increment = 0 +); + +/** + * BITOP + * + * Perform bitwise operations between strings + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int NWNX_Redis_BITOP( + string operation, + // Redis type: key + string destkey, + string key +); + +/** + * BITPOS + * + * Find first bit set or clear in a string + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int NWNX_Redis_BITPOS( + string key, + // Redis type: integer + int bit, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +); + +/** + * BLPOP + * + * Remove and get the first element in a list, or block until one is available + * + * Time complexity: O(1) + * Annotated return value: array + */ +int NWNX_Redis_BLPOP( + string key, + // Redis type: integer + int timeout +); + +/** + * BRPOP + * + * Remove and get the last element in a list, or block until one is available + * + * Time complexity: O(1) + * Annotated return value: array + */ +int NWNX_Redis_BRPOP( + string key, + // Redis type: integer + int timeout +); + +/** + * BRPOPLPUSH + * + * Pop a value from a list, push it to another list and return it; or block until one is available + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_BRPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination, + // Redis type: integer + int timeout +); + +/** + * BZPOPMIN + * + * Remove and return the member with the lowest score from one or more sorted sets, or block until one is available + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: array + */ +int NWNX_Redis_BZPOPMIN( + string key, + // Redis type: integer + int timeout +); + +/** + * BZPOPMAX + * + * Remove and return the member with the highest score from one or more sorted sets, or block until one is available + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: array + */ +int NWNX_Redis_BZPOPMAX( + string key, + // Redis type: integer + int timeout +); + +/** + * CLIENT_ID + * + * Returns the client ID for the current connection + * + * Time complexity: O(1) + * Annotated return value: + */ +int NWNX_Redis_CLIENT_ID(); + +/** + * CLIENT_KILL + * + * Kill the connection of a client + * + * Time complexity: O(N) where N is the number of client connections + * Annotated return value: simple-string + */ +int NWNX_Redis_CLIENT_KILL( + string ip_port = "", + // Redis type: integer + int id_client_id = 0, + string addr_ip_port = "", + string skipme_yes_no = "" +); + +/** + * CLIENT_LIST + * + * Get the list of client connections + * + * Time complexity: O(N) where N is the number of client connections + * Annotated return value: bulk-string + */ +int NWNX_Redis_CLIENT_LIST(); + +/** + * CLIENT_GETNAME + * + * Get the current connection name + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_CLIENT_GETNAME(); + +/** + * CLIENT_PAUSE + * + * Stop processing commands from clients for some time + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLIENT_PAUSE( + // Redis type: integer + int timeout +); + +/** + * CLIENT_REPLY + * + * Instruct the server whether to reply to commands + * + * Time complexity: O(1) + + * - Valid values for reply_mode: "ON", "OFF", "SKIP" + * Annotated return value: simple-string + */ +int NWNX_Redis_CLIENT_REPLY( + // Redis type: enum + string reply_mode +); + +/** + * CLIENT_SETNAME + * + * Set the current connection name + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLIENT_SETNAME( + string connection_name +); + +/** + * CLIENT_UNBLOCK + * + * Unblock a client blocked in a blocking command from a different connection + * + * Time complexity: O(log N) where N is the number of client connections + + * - Valid values for unblock_type: "TIMEOUT", "ERROR" + * Annotated return value: + */ +int NWNX_Redis_CLIENT_UNBLOCK( + string client_id, + // Redis type: enum + string unblock_type = "" +); + +/** + * CLUSTER_ADDSLOTS + * + * Assign new hash slots to receiving node + * + * Time complexity: O(N) where N is the total number of hash slot arguments + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_ADDSLOTS( + // Redis type: integer + int slot +); + +/** + * CLUSTER_COUNT_FAILURE_REPORTS + * + * Return the number of failure reports active for a given node + * + * Time complexity: O(N) where N is the number of failure reports + * Annotated return value: integer + */ +int NWNX_Redis_CLUSTER_COUNT_FAILURE_REPORTS( + string node_id +); + +/** + * CLUSTER_COUNTKEYSINSLOT + * + * Return the number of local keys in the specified hash slot + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_CLUSTER_COUNTKEYSINSLOT( + // Redis type: integer + int slot +); + +/** + * CLUSTER_DELSLOTS + * + * Set hash slots as unbound in receiving node + * + * Time complexity: O(N) where N is the total number of hash slot arguments + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_DELSLOTS( + // Redis type: integer + int slot +); + +/** + * CLUSTER_FAILOVER + * + * Forces a replica to perform a manual failover of its master. + * + * Time complexity: O(1) + + * - Valid values for options: "FORCE", "TAKEOVER" + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_FAILOVER( + // Redis type: enum + string options = "" +); + +/** + * CLUSTER_FORGET + * + * Remove a node from the nodes table + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_FORGET( + string node_id +); + +/** + * CLUSTER_GETKEYSINSLOT + * + * Return local key names in the specified hash slot + * + * Time complexity: O(log(N)) where N is the number of requested keys + * Annotated return value: array + */ +int NWNX_Redis_CLUSTER_GETKEYSINSLOT( + // Redis type: integer + int slot, + // Redis type: integer + int count +); + +/** + * CLUSTER_INFO + * + * Provides info about Redis Cluster node state + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_CLUSTER_INFO(); + +/** + * CLUSTER_KEYSLOT + * + * Returns the hash slot of the specified key + * + * Time complexity: O(N) where N is the number of bytes in the key + * Annotated return value: integer + */ +int NWNX_Redis_CLUSTER_KEYSLOT( + string key +); + +/** + * CLUSTER_MEET + * + * Force a node cluster to handshake with another node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_MEET( + string ip, + // Redis type: integer + int port +); + +/** + * CLUSTER_NODES + * + * Get Cluster config for the node + * + * Time complexity: O(N) where N is the total number of Cluster nodes + * Annotated return value: bulk-string + */ +int NWNX_Redis_CLUSTER_NODES(); + +/** + * CLUSTER_REPLICATE + * + * Reconfigure a node as a replica of the specified master node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_REPLICATE( + string node_id +); + +/** + * CLUSTER_RESET + * + * Reset a Redis Cluster node + * + * Time complexity: O(N) where N is the number of known nodes. The command may execute a + * FLUSHALL as a side effect. + + * - Valid values for reset_type: "HARD", "SOFT" + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_RESET( + // Redis type: enum + string reset_type = "" +); + +/** + * CLUSTER_SAVECONFIG + * + * Forces the node to save cluster state on disk + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_SAVECONFIG(); + +/** + * CLUSTER_SET_CONFIG_EPOCH + * + * Set the configuration epoch in a new node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_SET_CONFIG_EPOCH( + // Redis type: integer + int config_epoch +); + +/** + * CLUSTER_SETSLOT + * + * Bind a hash slot to a specific node + * + * Time complexity: O(1) + + * - Valid values for subcommand: "IMPORTING", "MIGRATING", "STABLE", "NODE" + * Annotated return value: simple-string + */ +int NWNX_Redis_CLUSTER_SETSLOT( + // Redis type: integer + int slot, + // Redis type: enum + string subcommand, + string node_id = "" +); + +/** + * CLUSTER_SLAVES + * + * List replica nodes of the specified master node + * + * Time complexity: O(1) + * Annotated return value: + */ +int NWNX_Redis_CLUSTER_SLAVES( + string node_id +); + +/** + * CLUSTER_REPLICAS + * + * List replica nodes of the specified master node + * + * Time complexity: O(1) + * Annotated return value: + */ +int NWNX_Redis_CLUSTER_REPLICAS( + string node_id +); + +/** + * CLUSTER_SLOTS + * + * Get array of Cluster slot to node mappings + * + * Time complexity: O(N) where N is the total number of Cluster nodes + * Annotated return value: array + */ +int NWNX_Redis_CLUSTER_SLOTS(); + +/** + * COMMAND + * + * Get array of Redis command details + * + * Time complexity: O(N) where N is the total number of Redis commands + * Annotated return value: array + */ +int NWNX_Redis_COMMAND(); + +/** + * COMMAND_COUNT + * + * Get total number of Redis commands + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_COMMAND_COUNT(); + +/** + * COMMAND_GETKEYS + * + * Extract keys given a full Redis command + * + * Time complexity: O(N) where N is the number of arguments to the command + * Annotated return value: array + */ +int NWNX_Redis_COMMAND_GETKEYS(); + +/** + * COMMAND_INFO + * + * Get array of specific Redis command details + * + * Time complexity: O(N) when N is number of commands to look up + * Annotated return value: array + */ +int NWNX_Redis_COMMAND_INFO( + string command_name +); + +/** + * CONFIG_GET + * + * Get the value of a configuration parameter + * Annotated return value: array + */ +int NWNX_Redis_CONFIG_GET( + string parameter +); + +/** + * CONFIG_REWRITE + * + * Rewrite the configuration file with the in memory configuration + * Annotated return value: simple-string + */ +int NWNX_Redis_CONFIG_REWRITE(); + +/** + * CONFIG_SET + * + * Set a configuration parameter to the given value + * Annotated return value: simple-string + */ +int NWNX_Redis_CONFIG_SET( + string parameter, + string value +); + +/** + * CONFIG_RESETSTAT + * + * Reset the stats returned by INFO + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_CONFIG_RESETSTAT(); + +/** + * DBSIZE + * + * Return the number of keys in the selected database + * Annotated return value: integer + */ +int NWNX_Redis_DBSIZE(); + +/** + * DEBUG_OBJECT + * + * Get debugging information about a key + * Annotated return value: simple-string + */ +int NWNX_Redis_DEBUG_OBJECT( + string key +); + +/** + * DEBUG_SEGFAULT + * + * Make the server crash + * Annotated return value: simple-string + */ +int NWNX_Redis_DEBUG_SEGFAULT(); + +/** + * DECR + * + * Decrement the integer value of a key by one + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_DECR( + string key +); + +/** + * DECRBY + * + * Decrement the integer value of a key by the given number + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_DECRBY( + string key, + // Redis type: integer + int decrement +); + +/** + * DEL + * + * Delete a key + * + * Time complexity: O(N) where N is the number of keys that will be removed. When a key to + * remove holds a value other than a string, the individual complexity for this + * key is O(M) where M is the number of elements in the list, set, sorted set + * or hash. Removing a single key that holds a string value is O(1). + * Annotated return value: integer + */ +int NWNX_Redis_DEL( + string key +); + +/** + * DISCARD + * + * Discard all commands issued after MULTI + * Annotated return value: simple-string + */ +int NWNX_Redis_DISCARD(); + +/** + * DUMP + * + * Return a serialized version of the value stored at the specified key. + * + * Time complexity: O(1) to access the key and additional O(N*M) to serialized it, where N is + * the number of Redis objects composing the value and M their average size. + * For small string values the time complexity is thus O(1)+O(1*M) where M is + * small, so simply O(1). + * Annotated return value: bulk-string + */ +int NWNX_Redis_DUMP( + string key +); + +/** + * ECHO + * + * Echo the given string + * Annotated return value: bulk-string + */ +int NWNX_Redis_ECHO( + string message +); + +/** + * EVAL + * + * Execute a Lua script server side + * + * Time complexity: Depends on the script that is executed. + * Annotated return value: + */ +int NWNX_Redis_EVAL( + string script, + // Redis type: integer + int numkeys, + string key, + string arg +); + +/** + * EVALSHA + * + * Execute a Lua script server side + * + * Time complexity: Depends on the script that is executed. + * Annotated return value: + */ +int NWNX_Redis_EVALSHA( + string sha1, + // Redis type: integer + int numkeys, + string key, + string arg +); + +/** + * EXEC + * + * Execute all commands issued after MULTI + * Annotated return value: array + */ +int NWNX_Redis_EXEC(); + +/** + * EXISTS + * + * Determine if a key exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_EXISTS( + string key +); + +/** + * EXPIRE + * + * Set a key's time to live in seconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_EXPIRE( + string key, + // Redis type: integer + int seconds +); + +/** + * EXPIREAT + * + * Set the expiration for a key as a UNIX timestamp + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_EXPIREAT( + string key, + // Redis type: posix time + string timestamp +); + +/** + * FLUSHALL + * + * Remove all keys from all databases + + * - Valid values for async: "ASYNC" + * Annotated return value: simple-string + */ +int NWNX_Redis_FLUSHALL( + // Redis type: enum + string async = "" +); + +/** + * FLUSHDB + * + * Remove all keys from the current database + + * - Valid values for async: "ASYNC" + * Annotated return value: simple-string + */ +int NWNX_Redis_FLUSHDB( + // Redis type: enum + string async = "" +); + +/** + * GEOADD + * + * Add one or more geospatial items in the geospatial index represented using a sorted set + * + * Time complexity: O(log(N)) for each item added, where N is the number of elements in the + * sorted set. + * Annotated return value: integer + */ +int NWNX_Redis_GEOADD( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + string member +); + +/** + * GEOHASH + * + * Returns members of a geospatial index as standard geohash strings + * + * Time complexity: O(log(N)) for each member requested, where N is the number of elements in + * the sorted set. + * Annotated return value: array + */ +int NWNX_Redis_GEOHASH( + string key, + string member +); + +/** + * GEOPOS + * + * Returns longitude and latitude of members of a geospatial index + * + * Time complexity: O(log(N)) for each member requested, where N is the number of elements in + * the sorted set. + * Annotated return value: array + */ +int NWNX_Redis_GEOPOS( + string key, + string member +); + +/** + * GEODIST + * + * Returns the distance between two members of a geospatial index + * + * Time complexity: O(log(N)) + * Annotated return value: bulk-string + */ +int NWNX_Redis_GEODIST( + string key, + string member1, + string member2, + string unit = "" +); + +/** + * GEORADIUS + * + * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point + * + * Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the + * circular area delimited by center and radius and M is the number of items + * inside the index. + + * - Valid values for unit: "m", "km", "ft", "mi" + + * - Valid values for withcoord: "WITHCOORD" + + * - Valid values for withdist: "WITHDIST" + + * - Valid values for withhash: "WITHHASH" + + * - Valid values for order: "ASC", "DESC" + * Annotated return value: array + */ +int NWNX_Redis_GEORADIUS( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +); + +/** + * GEORADIUSBYMEMBER + * + * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member + * + * Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the + * circular area delimited by center and radius and M is the number of items + * inside the index. + + * - Valid values for unit: "m", "km", "ft", "mi" + + * - Valid values for withcoord: "WITHCOORD" + + * - Valid values for withdist: "WITHDIST" + + * - Valid values for withhash: "WITHHASH" + + * - Valid values for order: "ASC", "DESC" + * Annotated return value: + */ +int NWNX_Redis_GEORADIUSBYMEMBER( + string key, + string member, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +); + +/** + * GET + * + * Get the value of a key + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_GET( + string key +); + +/** + * GETBIT + * + * Returns the bit value at offset in the string value stored at key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_GETBIT( + string key, + // Redis type: integer + int offset +); + +/** + * GETRANGE + * + * Get a substring of the string stored at a key + * + * Time complexity: O(N) where N is the length of the returned string. The complexity is + * ultimately determined by the returned length, but because creating a + * substring from an existing string is very cheap, it can be considered O(1) + * for small strings. + * Annotated return value: bulk-string + */ +int NWNX_Redis_GETRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int end +); + +/** + * GETSET + * + * Set the string value of a key and return its old value + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_GETSET( + string key, + string value +); + +/** + * HDEL + * + * Delete one or more hash fields + * + * Time complexity: O(N) where N is the number of fields to be removed. + * Annotated return value: integer + */ +int NWNX_Redis_HDEL( + string key, + string field +); + +/** + * HEXISTS + * + * Determine if a hash field exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HEXISTS( + string key, + string field +); + +/** + * HGET + * + * Get the value of a hash field + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_HGET( + string key, + string field +); + +/** + * HGETALL + * + * Get all the fields and values in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int NWNX_Redis_HGETALL( + string key +); + +/** + * HINCRBY + * + * Increment the integer value of a hash field by the given number + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HINCRBY( + string key, + string field, + // Redis type: integer + int increment +); + +/** + * HINCRBYFLOAT + * + * Increment the float value of a hash field by the given amount + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_HINCRBYFLOAT( + string key, + string field, + // Redis type: double + float increment +); + +/** + * HKEYS + * + * Get all the fields in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int NWNX_Redis_HKEYS( + string key +); + +/** + * HLEN + * + * Get the number of fields in a hash + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HLEN( + string key +); + +/** + * HMGET + * + * Get the values of all the given hash fields + * + * Time complexity: O(N) where N is the number of fields being requested. + * Annotated return value: array + */ +int NWNX_Redis_HMGET( + string key, + string field +); + +/** + * HMSET + * + * Set multiple hash fields to multiple values + * + * Time complexity: O(N) where N is the number of fields being set. + * Annotated return value: simple-string + */ +int NWNX_Redis_HMSET( + string key, + string field, + string value +); + +/** + * HSET + * + * Set the string value of a hash field + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HSET( + string key, + string field, + string value +); + +/** + * HSETNX + * + * Set the value of a hash field, only if the field does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HSETNX( + string key, + string field, + string value +); + +/** + * HSTRLEN + * + * Get the length of the value of a hash field + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_HSTRLEN( + string key, + string field +); + +/** + * HVALS + * + * Get all the values in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int NWNX_Redis_HVALS( + string key +); + +/** + * INCR + * + * Increment the integer value of a key by one + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_INCR( + string key +); + +/** + * INCRBY + * + * Increment the integer value of a key by the given amount + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_INCRBY( + string key, + // Redis type: integer + int increment +); + +/** + * INCRBYFLOAT + * + * Increment the float value of a key by the given amount + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_INCRBYFLOAT( + string key, + // Redis type: double + float increment +); + +/** + * INFO + * + * Get information and statistics about the server + * Annotated return value: bulk-string + */ +int NWNX_Redis_INFO( + string section = "" +); + +/** + * KEYS + * + * Find all keys matching the given pattern + * + * Time complexity: O(N) with N being the number of keys in the database, under the assumption + * that the key names in the database and the given pattern have limited + * length. + * Annotated return value: array + */ +int NWNX_Redis_KEYS( + string pattern +); + +/** + * LASTSAVE + * + * Get the UNIX time stamp of the last successful save to disk + * Annotated return value: integer + */ +int NWNX_Redis_LASTSAVE(); + +/** + * LINDEX + * + * Get an element from a list by its index + * + * Time complexity: O(N) where N is the number of elements to traverse to get to the element at + * index. This makes asking for the first or the last element of the list O(1). + * Annotated return value: bulk-string + */ +int NWNX_Redis_LINDEX( + string key, + // Redis type: integer + int index +); + +/** + * LINSERT + * + * Insert an element before or after another element in a list + * + * Time complexity: O(N) where N is the number of elements to traverse before seeing the value + * pivot. This means that inserting somewhere on the left end on the list + * (head) can be considered O(1) and inserting somewhere on the right end + * (tail) is O(N). + + * - Valid values for where: "BEFORE", "AFTER" + * Annotated return value: integer + */ +int NWNX_Redis_LINSERT( + string key, + // Redis type: enum + string where, + string pivot, + string value +); + +/** + * LLEN + * + * Get the length of a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_LLEN( + string key +); + +/** + * LPOP + * + * Remove and get the first element in a list + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_LPOP( + string key +); + +/** + * LPUSH + * + * Prepend one or multiple values to a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_LPUSH( + string key, + string value +); + +/** + * LPUSHX + * + * Prepend a value to a list, only if the list exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_LPUSHX( + string key, + string value +); + +/** + * LRANGE + * + * Get a range of elements from a list + * + * Time complexity: O(S+N) where S is the distance of start offset from HEAD for small lists, + * from nearest end (HEAD or TAIL) for large lists; and N is the number of + * elements in the specified range. + * Annotated return value: array + */ +int NWNX_Redis_LRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * LREM + * + * Remove elements from a list + * + * Time complexity: O(N) where N is the length of the list. + * Annotated return value: integer + */ +int NWNX_Redis_LREM( + string key, + // Redis type: integer + int count, + string value +); + +/** + * LSET + * + * Set the value of an element in a list by its index + * + * Time complexity: O(N) where N is the length of the list. Setting either the first or the last + * element of the list is O(1). + * Annotated return value: simple-string + */ +int NWNX_Redis_LSET( + string key, + // Redis type: integer + int index, + string value +); + +/** + * LTRIM + * + * Trim a list to the specified range + * + * Time complexity: O(N) where N is the number of elements to be removed by the operation. + * Annotated return value: simple-string + */ +int NWNX_Redis_LTRIM( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * MEMORY_DOCTOR + * + * Outputs memory problems report + * Annotated return value: bulk-string + */ +int NWNX_Redis_MEMORY_DOCTOR(); + +/** + * MEMORY_HELP + * + * Show helpful text about the different subcommands + * Annotated return value: array + */ +int NWNX_Redis_MEMORY_HELP(); + +/** + * MEMORY_MALLOC_STATS + * + * Show allocator internal stats + * Annotated return value: bulk-string + */ +int NWNX_Redis_MEMORY_MALLOC_STATS(); + +/** + * MEMORY_PURGE + * + * Ask the allocator to release memory + * Annotated return value: simple-string + */ +int NWNX_Redis_MEMORY_PURGE(); + +/** + * MEMORY_STATS + * + * Show memory usage details + * Annotated return value: array + */ +int NWNX_Redis_MEMORY_STATS(); + +/** + * MEMORY_USAGE + * + * Estimate the memory usage of a key + * + * Time complexity: O(N) where N is the number of samples. + * Annotated return value: integer + */ +int NWNX_Redis_MEMORY_USAGE( + string key, + // Redis type: integer + int samples_count = 0 +); + +/** + * MGET + * + * Get the values of all the given keys + * + * Time complexity: O(N) where N is the number of keys to retrieve. + * Annotated return value: array + */ +int NWNX_Redis_MGET( + string key +); + +/** + * MIGRATE + * + * Atomically transfer a key from a Redis instance to another one. + * + * Time complexity: This command actually executes a DUMP+DEL in the source instance, and a + * RESTORE in the target instance. See the pages of these commands for time + * complexity. Also an O(N) data transfer between the two instances is + * performed. + + * - Valid values for key: "key", "\"\"" + + * - Valid values for copy: "COPY" + + * - Valid values for replace: "REPLACE" + * Annotated return value: simple-string + */ +int NWNX_Redis_MIGRATE( + string host, + string port, + // Redis type: enum + string key, + // Redis type: integer + int destination_db, + // Redis type: integer + int timeout, + // Redis type: enum + string copy = "", + // Redis type: enum + string replace = "", + string auth_password = "", + // Redis type: key + string keys_key = "" +); + +/** + * MONITOR + * + * Listen for all requests received by the server in real time + * Annotated return value: + */ +int NWNX_Redis_MONITOR(); + +/** + * MOVE + * + * Move a key to another database + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_MOVE( + string key, + // Redis type: integer + int db +); + +/** + * MSET + * + * Set multiple keys to multiple values + * + * Time complexity: O(N) where N is the number of keys to set. + * Annotated return value: simple-string + */ +int NWNX_Redis_MSET( + string key, + string value +); + +/** + * MSETNX + * + * Set multiple keys to multiple values, only if none of the keys exist + * + * Time complexity: O(N) where N is the number of keys to set. + * Annotated return value: integer + */ +int NWNX_Redis_MSETNX( + string key, + string value +); + +/** + * MULTI + * + * Mark the start of a transaction block + * Annotated return value: simple-string + */ +int NWNX_Redis_MULTI(); + +/** + * OBJECT + * + * Inspect the internals of Redis objects + * + * Time complexity: O(1) for all the currently implemented subcommands. + * Annotated return value: + */ +int NWNX_Redis_OBJECT( + string subcommand, + string arguments = "" +); + +/** + * PERSIST + * + * Remove the expiration from a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_PERSIST( + string key +); + +/** + * PEXPIRE + * + * Set a key's time to live in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_PEXPIRE( + string key, + // Redis type: integer + int milliseconds +); + +/** + * PEXPIREAT + * + * Set the expiration for a key as a UNIX timestamp specified in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_PEXPIREAT( + string key, + // Redis type: posix time + string milliseconds_timestamp +); + +/** + * PFADD + * + * Adds the specified elements to the specified HyperLogLog. + * + * Time complexity: O(1) to add every element. + * Annotated return value: integer + */ +int NWNX_Redis_PFADD( + string key, + string element +); + +/** + * PFCOUNT + * + * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). + * + * Time complexity: O(1) with a very small average constant time when called with a single key. + * O(N) with N being the number of keys, and much bigger constant times, when + * called with multiple keys. + * Annotated return value: integer + */ +int NWNX_Redis_PFCOUNT( + string key +); + +/** + * PFMERGE + * + * Merge N different HyperLogLogs into a single one. + * + * Time complexity: O(N) to merge N HyperLogLogs, but with high constant times. + * Annotated return value: simple-string + */ +int NWNX_Redis_PFMERGE( + // Redis type: key + string destkey, + // Redis type: key + string sourcekey +); + +/** + * PING + * + * Ping the server + * Annotated return value: simple-string + */ +int NWNX_Redis_PING( + string message = "" +); + +/** + * PSETEX + * + * Set the value and expiration in milliseconds of a key + * + * Time complexity: O(1) + * Annotated return value: + */ +int NWNX_Redis_PSETEX( + string key, + // Redis type: integer + int milliseconds, + string value +); + +/** + * PUBSUB + * + * Inspect the state of the Pub/Sub subsystem + * + * Time complexity: O(N) for the CHANNELS subcommand, where N is the number of active channels, + * and assuming constant time pattern matching (relatively short channels and + * patterns). O(N) for the NUMSUB subcommand, where N is the number of + * requested channels. O(1) for the NUMPAT subcommand. + * Annotated return value: array + */ +int NWNX_Redis_PUBSUB( + string subcommand, + string argument = "" +); + +/** + * PTTL + * + * Get the time to live for a key in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_PTTL( + string key +); + +/** + * PUBLISH + * + * Post a message to a channel + * + * Time complexity: O(N+M) where N is the number of clients subscribed to the receiving channel + * and M is the total number of subscribed patterns (by any client). + * Annotated return value: integer + */ +int NWNX_Redis_PUBLISH( + string channel, + string message +); + +/** + * QUIT + * + * Close the connection + * Annotated return value: simple-string + */ +int NWNX_Redis_QUIT(); + +/** + * RANDOMKEY + * + * Return a random key from the keyspace + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_RANDOMKEY(); + +/** + * READONLY + * + * Enables read queries for a connection to a cluster replica node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_READONLY(); + +/** + * READWRITE + * + * Disables read queries for a connection to a cluster replica node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_READWRITE(); + +/** + * RENAME + * + * Rename a key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_RENAME( + string key, + // Redis type: key + string newkey +); + +/** + * RENAMENX + * + * Rename a key, only if the new key does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_RENAMENX( + string key, + // Redis type: key + string newkey +); + +/** + * RESTORE + * + * Create a key using the provided serialized value, previously obtained using DUMP. + * + * Time complexity: O(1) to create the new key and additional O(N*M) to reconstruct the + * serialized value, where N is the number of Redis objects composing the value + * and M their average size. For small string values the time complexity is + * thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set + * values the complexity is O(N*M*log(N)) because inserting values into sorted + * sets is O(log(N)). + + * - Valid values for replace: "REPLACE" + + * - Valid values for absttl: "ABSTTL" + * Annotated return value: simple-string + */ +int NWNX_Redis_RESTORE( + string key, + // Redis type: integer + int ttl, + string serialized_value, + // Redis type: enum + string replace = "", + // Redis type: enum + string absttl = "", + // Redis type: integer + int idletime_seconds = 0, + // Redis type: integer + int freq_frequency = 0 +); + +/** + * ROLE + * + * Return the role of the instance in the context of replication + * Annotated return value: array + */ +int NWNX_Redis_ROLE(); + +/** + * RPOP + * + * Remove and get the last element in a list + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_RPOP( + string key +); + +/** + * RPOPLPUSH + * + * Remove the last element in a list, prepend it to another list and return it + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_RPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination +); + +/** + * RPUSH + * + * Append one or multiple values to a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_RPUSH( + string key, + string value +); + +/** + * RPUSHX + * + * Append a value to a list, only if the list exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_RPUSHX( + string key, + string value +); + +/** + * SADD + * + * Add one or more members to a set + * + * Time complexity: O(1) for each element added, so O(N) to add N elements when the command is + * called with multiple arguments. + * Annotated return value: integer + */ +int NWNX_Redis_SADD( + string key, + string member +); + +/** + * SAVE + * + * Synchronously save the dataset to disk + * Annotated return value: simple-string + */ +int NWNX_Redis_SAVE(); + +/** + * SCARD + * + * Get the number of members in a set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_SCARD( + string key +); + +/** + * SCRIPT_DEBUG + * + * Set the debug mode for executed scripts. + * + * Time complexity: O(1) + + * - Valid values for mode: "YES", "SYNC", "NO" + * Annotated return value: simple-string + */ +int NWNX_Redis_SCRIPT_DEBUG( + // Redis type: enum + string mode +); + +/** + * SCRIPT_EXISTS + * + * Check existence of scripts in the script cache. + * + * Time complexity: O(N) with N being the number of scripts to check (so checking a single + * script is an O(1) operation). + * Annotated return value: array + */ +int NWNX_Redis_SCRIPT_EXISTS( + string sha1 +); + +/** + * SCRIPT_FLUSH + * + * Remove all the scripts from the script cache. + * + * Time complexity: O(N) with N being the number of scripts in cache + * Annotated return value: simple-string + */ +int NWNX_Redis_SCRIPT_FLUSH(); + +/** + * SCRIPT_KILL + * + * Kill the script currently in execution. + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_SCRIPT_KILL(); + +/** + * SCRIPT_LOAD + * + * Load the specified Lua script into the script cache. + * + * Time complexity: O(N) with N being the length in bytes of the script body. + * Annotated return value: bulk-string + */ +int NWNX_Redis_SCRIPT_LOAD( + string script +); + +/** + * SDIFF + * + * Subtract multiple sets + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: array + */ +int NWNX_Redis_SDIFF( + string key +); + +/** + * SDIFFSTORE + * + * Subtract multiple sets and store the resulting set in a key + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: integer + */ +int NWNX_Redis_SDIFFSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SELECT + * + * Change the selected database for the current connection + * Annotated return value: simple-string + */ +int NWNX_Redis_SELECT( + // Redis type: integer + int index +); + +/** + * SET + * + * Set the string value of a key + * + * Time complexity: O(1) + + * - Valid values for condition: "NX", "XX" + * Annotated return value: simple-string + */ +int NWNX_Redis_SET( + string key, + string value, + // Redis type: enum + string condition = "" +); + +/** + * SETBIT + * + * Sets or clears the bit at offset in the string value stored at key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_SETBIT( + string key, + // Redis type: integer + int offset, + string value +); + +/** + * SETEX + * + * Set the value and expiration of a key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_SETEX( + string key, + // Redis type: integer + int seconds, + string value +); + +/** + * SETNX + * + * Set the value of a key, only if the key does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_SETNX( + string key, + string value +); + +/** + * SETRANGE + * + * Overwrite part of a string at key starting at the specified offset + * + * Time complexity: O(1), not counting the time taken to copy the new string in place. Usually, + * this string is very small so the amortized complexity is O(1). Otherwise, + * complexity is O(M) with M being the length of the value argument. + * Annotated return value: integer + */ +int NWNX_Redis_SETRANGE( + string key, + // Redis type: integer + int offset, + string value +); + +/** + * SHUTDOWN + * + * Synchronously save the dataset to disk and then shut down the server + + * - Valid values for save_mode: "NOSAVE", "SAVE" + * Annotated return value: simple-string + */ +int NWNX_Redis_SHUTDOWN( + // Redis type: enum + string save_mode = "" +); + +/** + * SINTER + * + * Intersect multiple sets + * + * Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is + * the number of sets. + * Annotated return value: array + */ +int NWNX_Redis_SINTER( + string key +); + +/** + * SINTERSTORE + * + * Intersect multiple sets and store the resulting set in a key + * + * Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is + * the number of sets. + * Annotated return value: integer + */ +int NWNX_Redis_SINTERSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SISMEMBER + * + * Determine if a given value is a member of a set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_SISMEMBER( + string key, + string member +); + +/** + * SLAVEOF + * + * Make the server a replica of another instance, or promote it as master. Deprecated starting with Redis 5. Use REPLICAOF instead. + * Annotated return value: simple-string + */ +int NWNX_Redis_SLAVEOF( + string host, + string port +); + +/** + * REPLICAOF + * + * Make the server a replica of another instance, or promote it as master. + * Annotated return value: simple-string + */ +int NWNX_Redis_REPLICAOF( + string host, + string port +); + +/** + * SLOWLOG + * + * Manages the Redis slow queries log + * Annotated return value: + */ +int NWNX_Redis_SLOWLOG( + string subcommand, + string argument = "" +); + +/** + * SMEMBERS + * + * Get all the members in a set + * + * Time complexity: O(N) where N is the set cardinality. + * Annotated return value: array + */ +int NWNX_Redis_SMEMBERS( + string key +); + +/** + * SMOVE + * + * Move a member from one set to another + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_SMOVE( + // Redis type: key + string source, + // Redis type: key + string destination, + string member +); + +/** + * SORT + * + * Sort the elements in a list, set or sorted set + * + * Time complexity: O(N+M*log(M)) where N is the number of elements in the list or set to sort, + * and M the number of returned elements. When the elements are not sorted, + * complexity is currently O(N) as there is a copy step that will be avoided in + * next releases. + + * - Valid values for order: "ASC", "DESC" + + * - Valid values for sorting: "ALPHA" + * Annotated return value: array + */ +int NWNX_Redis_SORT( + string key, + // Redis type: pattern + string by_pattern = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0, + string get_pattern = "", + // Redis type: enum + string order = "", + // Redis type: enum + string sorting = "", + // Redis type: key + string store_destination = "" +); + +/** + * SPOP + * + * Remove and return one or multiple random members from a set + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_SPOP( + string key, + // Redis type: integer + int count = 0 +); + +/** + * SRANDMEMBER + * + * Get one or multiple random members from a set + * + * Time complexity: Without the count argument O(1), otherwise O(N) where N is the absolute + * value of the passed count. + * Annotated return value: bulk-string + */ +int NWNX_Redis_SRANDMEMBER( + string key, + // Redis type: integer + int count = 0 +); + +/** + * SREM + * + * Remove one or more members from a set + * + * Time complexity: O(N) where N is the number of members to be removed. + * Annotated return value: integer + */ +int NWNX_Redis_SREM( + string key, + string member +); + +/** + * STRLEN + * + * Get the length of the value stored in a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_STRLEN( + string key +); + +/** + * SUNION + * + * Add multiple sets + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: array + */ +int NWNX_Redis_SUNION( + string key +); + +/** + * SUNIONSTORE + * + * Add multiple sets and store the resulting set in a key + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: integer + */ +int NWNX_Redis_SUNIONSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SWAPDB + * + * Swaps two Redis databases + * Annotated return value: simple-string + */ +int NWNX_Redis_SWAPDB( + // Redis type: integer + int index, + // Redis type: integer + int index_1 +); + +/** + * SYNC + * + * Internal command used for replication + * Annotated return value: + */ +int NWNX_Redis_SYNC(); + +/** + * TIME + * + * Return the current server time + * + * Time complexity: O(1) + * Annotated return value: array + */ +int NWNX_Redis_TIME(); + +/** + * TOUCH + * + * Alters the last access time of a key(s). Returns the number of existing keys specified. + * + * Time complexity: O(N) where N is the number of keys that will be touched. + * Annotated return value: integer + */ +int NWNX_Redis_TOUCH( + string key +); + +/** + * TTL + * + * Get the time to live for a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_TTL( + string key +); + +/** + * TYPE + * + * Determine the type stored at key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_TYPE( + string key +); + +/** + * UNLINK + * + * Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking. + * + * Time complexity: O(1) for each key removed regardless of its size. Then the command does O(N) + * work in a different thread in order to reclaim memory, where N is the number + * of allocations the deleted objects where composed of. + * Annotated return value: integer + */ +int NWNX_Redis_UNLINK( + string key +); + +/** + * UNWATCH + * + * Forget about all watched keys + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int NWNX_Redis_UNWATCH(); + +/** + * WAIT + * + * Wait for the synchronous replication of all the write commands sent in the context of the current connection + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_WAIT( + // Redis type: integer + int numreplicas, + // Redis type: integer + int timeout +); + +/** + * WATCH + * + * Watch the given keys to determine execution of the MULTI/EXEC block + * + * Time complexity: O(1) for every key. + * Annotated return value: simple-string + */ +int NWNX_Redis_WATCH( + string key +); + +/** + * ZADD + * + * Add one or more members to a sorted set, or update its score if it already exists + * + * Time complexity: O(log(N)) for each item added, where N is the number of elements in the + * sorted set. + + * - Valid values for condition: "NX", "XX" + + * - Valid values for change: "CH" + + * - Valid values for increment: "INCR" + * Annotated return value: integer + */ +int NWNX_Redis_ZADD( + string key, + // Redis type: enum + string condition = "", + // Redis type: enum + string change = "", + // Redis type: enum + string increment = "", + // Redis type: double + float score = 0.0, + string member = "" +); + +/** + * ZCARD + * + * Get the number of members in a sorted set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_ZCARD( + string key +); + +/** + * ZCOUNT + * + * Count the members in a sorted set with scores within the given values + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: integer + */ +int NWNX_Redis_ZCOUNT( + string key, + // Redis type: double + float min, + // Redis type: double + float max +); + +/** + * ZINCRBY + * + * Increment the score of a member in a sorted set + * + * Time complexity: O(log(N)) where N is the number of elements in the sorted set. + * Annotated return value: bulk-string + */ +int NWNX_Redis_ZINCRBY( + string key, + // Redis type: integer + int increment, + string member +); + +/** + * ZINTERSTORE + * + * Intersect multiple sorted sets and store the resulting sorted set in a new key + * + * Time complexity: O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K + * being the number of input sorted sets and M being the number of elements in + * the resulting sorted set. + + * - Valid values for aggregate_aggregate: "SUM", "MIN", "MAX" + * Annotated return value: integer + */ +int NWNX_Redis_ZINTERSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +); + +/** + * ZLEXCOUNT + * + * Count the number of members in a sorted set between a given lexicographical range + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: integer + */ +int NWNX_Redis_ZLEXCOUNT( + string key, + string min, + string max +); + +/** + * ZPOPMAX + * + * Remove and return members with the highest scores in a sorted set + * + * Time complexity: O(log(N)*M) with N being the number of elements in the sorted set, and M + * being the number of elements popped. + * Annotated return value: array + */ +int NWNX_Redis_ZPOPMAX( + string key, + // Redis type: integer + int count = 0 +); + +/** + * ZPOPMIN + * + * Remove and return members with the lowest scores in a sorted set + * + * Time complexity: O(log(N)*M) with N being the number of elements in the sorted set, and M + * being the number of elements popped. + * Annotated return value: array + */ +int NWNX_Redis_ZPOPMIN( + string key, + // Redis type: integer + int count = 0 +); + +/** + * ZRANGE + * + * Return a range of members in a sorted set, by index + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements returned. + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int NWNX_Redis_ZRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +); + +/** + * ZRANGEBYLEX + * + * Return a range of members in a sorted set, by lexicographical range + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + * Annotated return value: array + */ +int NWNX_Redis_ZRANGEBYLEX( + string key, + string min, + string max, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZREVRANGEBYLEX + * + * Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings. + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + * Annotated return value: array + */ +int NWNX_Redis_ZREVRANGEBYLEX( + string key, + string max, + string min, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZRANGEBYSCORE + * + * Return a range of members in a sorted set, by score + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int NWNX_Redis_ZRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZRANK + * + * Determine the index of a member in a sorted set + * + * Time complexity: O(log(N)) + * Annotated return value: integer + */ +int NWNX_Redis_ZRANK( + string key, + string member +); + +/** + * ZREM + * + * Remove one or more members from a sorted set + * + * Time complexity: O(M*log(N)) with N being the number of elements in the sorted set and M the + * number of elements to be removed. + * Annotated return value: integer + */ +int NWNX_Redis_ZREM( + string key, + string member +); + +/** + * ZREMRANGEBYLEX + * + * Remove all members in a sorted set between the given lexicographical range + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int NWNX_Redis_ZREMRANGEBYLEX( + string key, + string min, + string max +); + +/** + * ZREMRANGEBYRANK + * + * Remove all members in a sorted set within the given indexes + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int NWNX_Redis_ZREMRANGEBYRANK( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * ZREMRANGEBYSCORE + * + * Remove all members in a sorted set within the given scores + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int NWNX_Redis_ZREMRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max +); + +/** + * ZREVRANGE + * + * Return a range of members in a sorted set, by index, with scores ordered from high to low + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements returned. + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int NWNX_Redis_ZREVRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +); + +/** + * ZREVRANGEBYSCORE + * + * Return a range of members in a sorted set, by score, with scores ordered from high to low + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int NWNX_Redis_ZREVRANGEBYSCORE( + string key, + // Redis type: double + float max, + // Redis type: double + float min, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZREVRANK + * + * Determine the index of a member in a sorted set, with scores ordered from high to low + * + * Time complexity: O(log(N)) + * Annotated return value: integer + */ +int NWNX_Redis_ZREVRANK( + string key, + string member +); + +/** + * ZSCORE + * + * Get the score associated with the given member in a sorted set + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_ZSCORE( + string key, + string member +); + +/** + * ZUNIONSTORE + * + * Add multiple sorted sets and store the resulting sorted set in a new key + * + * Time complexity: O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, + * and M being the number of elements in the resulting sorted set. + + * - Valid values for aggregate_aggregate: "SUM", "MIN", "MAX" + * Annotated return value: integer + */ +int NWNX_Redis_ZUNIONSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +); + +/** + * SCAN + * + * Incrementally iterate the keys space + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection. + * Annotated return value: + */ +int NWNX_Redis_SCAN( + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0, + string type_type = "" +); + +/** + * SSCAN + * + * Incrementally iterate Set elements + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int NWNX_Redis_SSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * HSCAN + * + * Incrementally iterate hash fields and associated values + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int NWNX_Redis_HSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * ZSCAN + * + * Incrementally iterate sorted sets elements and associated scores + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int NWNX_Redis_ZSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * XINFO + * + * Get information on streams and consumer groups + * + * Time complexity: O(N) with N being the number of returned items for the subcommands CONSUMERS + * and GROUPS. The STREAM subcommand is O(log N) with N being the number of + * items in the stream. + + * - Valid values for help: "HELP" + * Annotated return value: + */ +int NWNX_Redis_XINFO( + // Redis type: key + string consumers_key = "", + string consumers_groupname = "", + // Redis type: key + string groups_key = "", + // Redis type: key + string stream_key = "", + // Redis type: enum + string help = "" +); + +/** + * XADD + * + * Appends a new entry to a stream + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int NWNX_Redis_XADD( + string key, + string ID, + // Redis type: value + string field, + string str +); + +/** + * XTRIM + * + * Trims the stream to (approximately if '~' is passed) a certain size + * + * Time complexity: O(N), with N being the number of evicted entries. Constant times are very + * small however, since entries are organized in macro nodes containing + * multiple entries that can be released with a single deallocation. + + * - Valid values for strategy: "MAXLEN" + + * - Valid values for approx: "~" + * Annotated return value: integer + */ +int NWNX_Redis_XTRIM( + string key, + // Redis type: enum + string strategy, + // Redis type: enum + string approx = "", + // Redis type: integer + int count = 0 +); + +/** + * XDEL + * + * Removes the specified entries from the stream. Returns the number of items actually deleted, that may be different from the number of IDs passed in case certain IDs do not exist. + * + * Time complexity: O(1) for each single item to delete in the stream, regardless of the stream + * size. + * Annotated return value: integer + */ +int NWNX_Redis_XDEL( + string key, + string ID +); + +/** + * XRANGE + * + * Return a range of elements in a stream, with IDs matching the specified IDs interval + * + * Time complexity: O(N) with N being the number of elements being returned. If N is constant + * (e.g. always asking for the first 10 elements with COUNT), you can consider + * it O(1). + * Annotated return value: array + */ +int NWNX_Redis_XRANGE( + string key, + string start, + string end, + // Redis type: integer + int count_count = 0 +); + +/** + * XREVRANGE + * + * Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE + * + * Time complexity: O(N) with N being the number of elements returned. If N is constant (e.g. + * always asking for the first 10 elements with COUNT), you can consider it + * O(1). + * Annotated return value: array + */ +int NWNX_Redis_XREVRANGE( + string key, + string end, + string start, + // Redis type: integer + int count_count = 0 +); + +/** + * XLEN + * + * Return the number of entires in a stream + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int NWNX_Redis_XLEN( + string key +); + +/** + * XREAD + * + * Return never seen elements in multiple streams, with IDs greater than the ones reported by the caller for each stream. Can block. + * + * Time complexity: For each stream mentioned: O(N) with N being the number of elements being + * returned, it menas that XREAD-ing with a fixed COUNT is O(1). Note that when + * the BLOCK option is used, XADD will pay O(M) time in order to serve the M + * clients blocked on the stream getting new data. + + * - Valid values for streams: "STREAMS" + * Annotated return value: array + */ +int NWNX_Redis_XREAD( + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +); + +/** + * XGROUP + * + * Create, destroy, and manage consumer groups. + * + * Time complexity: O(1) for all the subcommands, with the exception of the DESTROY subcommand + * which takes an additional O(M) time in order to delete the M entries inside + * the consumer group pending entries list (PEL). + * Annotated return value: + */ +int NWNX_Redis_XGROUP( + // Redis type: key + string create_key = "", + string create_groupname = "", + string create_id_or__ = "", + // Redis type: key + string setid_key = "", + string setid_groupname = "", + string setid_id_or__ = "", + // Redis type: key + string destroy_key = "", + string destroy_groupname = "", + // Redis type: key + string delconsumer_key = "", + string delconsumer_groupname = "", + string delconsumer_consumername = "" +); + +/** + * XREADGROUP + * + * Return new entries from a stream using a consumer group, or access the history of the pending entries for a given consumer. Can block. + * + * Time complexity: For each stream mentioned: O(M) with M being the number of elements + * returned. If M is constant (e.g. always asking for the first 10 elements + * with COUNT), you can consider it O(1). On the other side when XREADGROUP + * blocks, XADD will pay the O(N) time in order to serve the N clients blocked + * on the stream getting new data. + + * - Valid values for noack: "NOACK" + + * - Valid values for streams: "STREAMS" + * Annotated return value: + */ +int NWNX_Redis_XREADGROUP( + string group_group, + string group_consumer, + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string noack = "", + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +); + +/** + * XACK + * + * Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL. + * + * Time complexity: O(1) for each message ID processed. + * Annotated return value: integer + */ +int NWNX_Redis_XACK( + string key, + string group, + string ID +); + +/** + * XCLAIM + * + * Changes (or acquires) ownership of a message in a consumer group, as if the message was delivered to the specified consumer. + * + * Time complexity: O(log N) with N being the number of messages in the PEL of the consumer + * group. + * Annotated return value: array + */ +int NWNX_Redis_XCLAIM( + string key, + string group, + string consumer, + string min_idle_time, + string ID, + // Redis type: integer + int idle_ms = 0, + // Redis type: integer + int time_ms_unix_time = 0, + // Redis type: integer + int retrycount_count = 0 +); + +/** + * XPENDING + * + * Return information and entries from a stream consumer group pending entries list, that are messages fetched but never acknowledged. + * + * Time complexity: O(N) with N being the number of elements returned, so asking for a small + * fixed number of entries per call is O(1). When the command returns just the + * summary it runs in O(1) time assuming the list of consumers is small, + * otherwise there is additional O(N) time needed to iterate every consumer. + * Annotated return value: array + */ +int NWNX_Redis_XPENDING( + string key, + string group, + string start = "", + string end = "", + // Redis type: integer + int count = 0, + string consumer = "" +); + + + +// Implementation below +int NWNX_Redis_APPEND( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "APPEND"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_AUTH( + string password +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "AUTH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", password); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BGREWRITEAOF() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BGREWRITEAOF"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BGSAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BGSAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BITCOUNT( + string key, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (start != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + if (end != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BITFIELD( + string key, + // Redis type: type + string get_type = "", + // Redis type: integer + int get_offset = 0, + // Redis type: type + string set_type = "", + // Redis type: integer + int set_offset = 0, + // Redis type: integer + int set_value = 0, + // Redis type: type + string incrby_type = "", + // Redis type: integer + int incrby_offset = 0, + // Redis type: integer + int incrby_increment = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITFIELD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (get_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", get_type); + if (get_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(get_offset)); + if (set_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", set_type); + if (set_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(set_offset)); + if (set_value != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(set_value)); + if (incrby_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", incrby_type); + if (incrby_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(incrby_offset)); + if (incrby_increment != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(incrby_increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BITOP( + string operation, + // Redis type: key + string destkey, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", operation); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destkey); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BITPOS( + string key, + // Redis type: integer + int bit, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITPOS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(bit)); + if (start != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + if (end != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BLPOP( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BLPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BRPOP( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BRPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BRPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BRPOPLPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BZPOPMIN( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BZPOPMIN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_BZPOPMAX( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BZPOPMAX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_ID() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_ID"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_KILL( + string ip_port = "", + // Redis type: integer + int id_client_id = 0, + string addr_ip_port = "", + string skipme_yes_no = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_KILL"); + if (ip_port != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", ip_port); + if (id_client_id != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(id_client_id)); + if (addr_ip_port != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", addr_ip_port); + if (skipme_yes_no != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", skipme_yes_no); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_LIST() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_LIST"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_GETNAME() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_GETNAME"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_PAUSE( + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_PAUSE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_REPLY( + // Redis type: enum + string reply_mode +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_REPLY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", reply_mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_SETNAME( + string connection_name +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_SETNAME"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", connection_name); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLIENT_UNBLOCK( + string client_id, + // Redis type: enum + string unblock_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_UNBLOCK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", client_id); + if (unblock_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", unblock_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_ADDSLOTS( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_ADDSLOTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_COUNT_FAILURE_REPORTS( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_COUNT_FAILURE_REPORTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_COUNTKEYSINSLOT( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_COUNTKEYSINSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_DELSLOTS( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_DELSLOTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_FAILOVER( + // Redis type: enum + string options = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_FAILOVER"); + if (options != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", options); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_FORGET( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_FORGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_GETKEYSINSLOT( + // Redis type: integer + int slot, + // Redis type: integer + int count +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_GETKEYSINSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_INFO() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_INFO"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_KEYSLOT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_KEYSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_MEET( + string ip, + // Redis type: integer + int port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_MEET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ip); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(port)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_NODES() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_NODES"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_REPLICATE( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_REPLICATE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_RESET( + // Redis type: enum + string reset_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_RESET"); + if (reset_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", reset_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_SAVECONFIG() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SAVECONFIG"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_SET_CONFIG_EPOCH( + // Redis type: integer + int config_epoch +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SET_CONFIG_EPOCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(config_epoch)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_SETSLOT( + // Redis type: integer + int slot, + // Redis type: enum + string subcommand, + string node_id = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SETSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (node_id != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_SLAVES( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SLAVES"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_REPLICAS( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_REPLICAS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CLUSTER_SLOTS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SLOTS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_COMMAND() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_COMMAND_COUNT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_COUNT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_COMMAND_GETKEYS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_GETKEYS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_COMMAND_INFO( + string command_name +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_INFO"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", command_name); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CONFIG_GET( + string parameter +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_GET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", parameter); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CONFIG_REWRITE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_REWRITE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CONFIG_SET( + string parameter, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_SET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", parameter); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_CONFIG_RESETSTAT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_RESETSTAT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DBSIZE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DBSIZE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DEBUG_OBJECT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEBUG_OBJECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DEBUG_SEGFAULT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEBUG_SEGFAULT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DECR( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DECR"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DECRBY( + string key, + // Redis type: integer + int decrement +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DECRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(decrement)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DEL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DISCARD() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DISCARD"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_DUMP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DUMP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ECHO( + string message +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ECHO"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EVAL( + string script, + // Redis type: integer + int numkeys, + string key, + string arg +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EVAL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", script); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", arg); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EVALSHA( + string sha1, + // Redis type: integer + int numkeys, + string key, + string arg +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EVALSHA"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sha1); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", arg); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EXEC() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXEC"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EXISTS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EXPIRE( + string key, + // Redis type: integer + int seconds +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXPIRE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(seconds)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_EXPIREAT( + string key, + // Redis type: posix time + string timestamp +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXPIREAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", timestamp); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_FLUSHALL( + // Redis type: enum + string async = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "FLUSHALL"); + if (async != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", async); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_FLUSHDB( + // Redis type: enum + string async = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "FLUSHDB"); + if (async != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", async); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEOADD( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(longitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(latitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEOHASH( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOHASH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEOPOS( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOPOS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEODIST( + string key, + string member1, + string member2, + string unit = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEODIST"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member1); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member2); + if (unit != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEORADIUS( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEORADIUS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(longitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(latitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(radius, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + if (withcoord != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withcoord); + if (withdist != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withdist); + if (withhash != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withhash); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (store_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_key); + if (storedist_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", storedist_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GEORADIUSBYMEMBER( + string key, + string member, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEORADIUSBYMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(radius, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + if (withcoord != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withcoord); + if (withdist != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withdist); + if (withhash != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withhash); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (store_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_key); + if (storedist_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", storedist_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GET( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GETBIT( + string key, + // Redis type: integer + int offset +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETBIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GETRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int end +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_GETSET( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HDEL( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HDEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HEXISTS( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HEXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HGET( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HGETALL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HGETALL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HINCRBY( + string key, + string field, + // Redis type: integer + int increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HINCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HINCRBYFLOAT( + string key, + string field, + // Redis type: double + float increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HINCRBYFLOAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(increment, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HKEYS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HKEYS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HMGET( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HMGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HMSET( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HMSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HSET( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HSETNX( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HSTRLEN( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSTRLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HVALS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HVALS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_INCR( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCR"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_INCRBY( + string key, + // Redis type: integer + int increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_INCRBYFLOAT( + string key, + // Redis type: double + float increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCRBYFLOAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(increment, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_INFO( + string section = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INFO"); + if (section != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", section); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_KEYS( + string pattern +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "KEYS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", pattern); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LASTSAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LASTSAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LINDEX( + string key, + // Redis type: integer + int index +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LINDEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LINSERT( + string key, + // Redis type: enum + string where, + string pivot, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LINSERT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", where); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", pivot); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LPOP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LPUSH( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LPUSHX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPUSHX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LREM( + string key, + // Redis type: integer + int count, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LSET( + string key, + // Redis type: integer + int index, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_LTRIM( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LTRIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_DOCTOR() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_DOCTOR"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_HELP() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_HELP"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_MALLOC_STATS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_MALLOC_STATS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_PURGE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_PURGE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_STATS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_STATS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MEMORY_USAGE( + string key, + // Redis type: integer + int samples_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_USAGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (samples_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(samples_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MGET( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MIGRATE( + string host, + string port, + // Redis type: enum + string key, + // Redis type: integer + int destination_db, + // Redis type: integer + int timeout, + // Redis type: enum + string copy = "", + // Redis type: enum + string replace = "", + string auth_password = "", + // Redis type: key + string keys_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MIGRATE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(destination_db)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + if (copy != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", copy); + if (replace != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", replace); + if (auth_password != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", auth_password); + if (keys_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", keys_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MONITOR() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MONITOR"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MOVE( + string key, + // Redis type: integer + int db +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MOVE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(db)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MSET( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MSETNX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MSETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_MULTI() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MULTI"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_OBJECT( + string subcommand, + string arguments = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "OBJECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (arguments != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", arguments); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PERSIST( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PERSIST"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PEXPIRE( + string key, + // Redis type: integer + int milliseconds +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PEXPIRE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(milliseconds)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PEXPIREAT( + string key, + // Redis type: posix time + string milliseconds_timestamp +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PEXPIREAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", milliseconds_timestamp); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PFADD( + string key, + string element +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", element); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PFCOUNT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PFMERGE( + // Redis type: key + string destkey, + // Redis type: key + string sourcekey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFMERGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destkey); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sourcekey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PING( + string message = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PING"); + if (message != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PSETEX( + string key, + // Redis type: integer + int milliseconds, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PSETEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(milliseconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PUBSUB( + string subcommand, + string argument = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PUBSUB"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (argument != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", argument); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PTTL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PTTL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_PUBLISH( + string channel, + string message +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PUBLISH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", channel); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_QUIT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "QUIT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RANDOMKEY() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RANDOMKEY"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_READONLY() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "READONLY"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_READWRITE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "READWRITE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RENAME( + string key, + // Redis type: key + string newkey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RENAME"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", newkey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RENAMENX( + string key, + // Redis type: key + string newkey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RENAMENX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", newkey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RESTORE( + string key, + // Redis type: integer + int ttl, + string serialized_value, + // Redis type: enum + string replace = "", + // Redis type: enum + string absttl = "", + // Redis type: integer + int idletime_seconds = 0, + // Redis type: integer + int freq_frequency = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RESTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(ttl)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", serialized_value); + if (replace != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", replace); + if (absttl != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", absttl); + if (idletime_seconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(idletime_seconds)); + if (freq_frequency != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(freq_frequency)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ROLE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ROLE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RPOP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPOPLPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RPUSH( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_RPUSHX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPUSHX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SADD( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCARD( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCARD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCRIPT_DEBUG( + // Redis type: enum + string mode +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_DEBUG"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCRIPT_EXISTS( + string sha1 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_EXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sha1); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCRIPT_FLUSH() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_FLUSH"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCRIPT_KILL() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_KILL"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCRIPT_LOAD( + string script +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_LOAD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", script); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SDIFF( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SDIFF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SDIFFSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SDIFFSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SELECT( + // Redis type: integer + int index +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SELECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SET( + string key, + string value, + // Redis type: enum + string condition = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + if (condition != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", condition); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SETBIT( + string key, + // Redis type: integer + int offset, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETBIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SETEX( + string key, + // Redis type: integer + int seconds, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(seconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SETNX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SETRANGE( + string key, + // Redis type: integer + int offset, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SHUTDOWN( + // Redis type: enum + string save_mode = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SHUTDOWN"); + if (save_mode != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", save_mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SINTER( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SINTER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SINTERSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SINTERSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SISMEMBER( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SISMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SLAVEOF( + string host, + string port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SLAVEOF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_REPLICAOF( + string host, + string port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "REPLICAOF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SLOWLOG( + string subcommand, + string argument = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SLOWLOG"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (argument != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", argument); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SMEMBERS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SMEMBERS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SMOVE( + // Redis type: key + string source, + // Redis type: key + string destination, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SMOVE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SORT( + string key, + // Redis type: pattern + string by_pattern = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0, + string get_pattern = "", + // Redis type: enum + string order = "", + // Redis type: enum + string sorting = "", + // Redis type: key + string store_destination = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SORT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (by_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", by_pattern); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + if (get_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", get_pattern); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (sorting != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", sorting); + if (store_destination != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_destination); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SPOP( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SRANDMEMBER( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SRANDMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SREM( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_STRLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "STRLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SUNION( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SUNION"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SUNIONSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SUNIONSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SWAPDB( + // Redis type: integer + int index, + // Redis type: integer + int index_1 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SWAPDB"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index_1)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SYNC() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SYNC"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_TIME() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TIME"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_TOUCH( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TOUCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_TTL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TTL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_TYPE( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TYPE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_UNLINK( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "UNLINK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_UNWATCH() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "UNWATCH"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_WAIT( + // Redis type: integer + int numreplicas, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "WAIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numreplicas)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_WATCH( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "WATCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZADD( + string key, + // Redis type: enum + string condition = "", + // Redis type: enum + string change = "", + // Redis type: enum + string increment = "", + // Redis type: double + float score = 0.0, + string member = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (condition != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", condition); + if (change != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", change); + if (increment != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", increment); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(score, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZCARD( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZCARD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZCOUNT( + string key, + // Redis type: double + float min, + // Redis type: double + float max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZINCRBY( + string key, + // Redis type: integer + int increment, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZINCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZINTERSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZINTERSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (weights_weight != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(weights_weight)); + if (aggregate_aggregate != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", aggregate_aggregate); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZLEXCOUNT( + string key, + string min, + string max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZLEXCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZPOPMAX( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZPOPMAX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZPOPMIN( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZPOPMIN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZRANGEBYLEX( + string key, + string min, + string max, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREVRANGEBYLEX( + string key, + string max, + string min, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZRANK( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREM( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREMRANGEBYLEX( + string key, + string min, + string max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREMRANGEBYRANK( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREMRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREVRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREVRANGEBYSCORE( + string key, + // Redis type: double + float max, + // Redis type: double + float min, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZREVRANK( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZSCORE( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZUNIONSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZUNIONSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (weights_weight != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(weights_weight)); + if (aggregate_aggregate != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", aggregate_aggregate); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SCAN( + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0, + string type_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (type_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", type_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_SSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_HSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_ZSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XINFO( + // Redis type: key + string consumers_key = "", + string consumers_groupname = "", + // Redis type: key + string groups_key = "", + // Redis type: key + string stream_key = "", + // Redis type: enum + string help = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XINFO"); + if (consumers_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumers_key); + if (consumers_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumers_groupname); + if (groups_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", groups_key); + if (stream_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", stream_key); + if (help != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", help); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XADD( + string key, + string ID, + // Redis type: value + string field, + string str +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", str); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XTRIM( + string key, + // Redis type: enum + string strategy, + // Redis type: enum + string approx = "", + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XTRIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", strategy); + if (approx != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", approx); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XDEL( + string key, + string ID +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XDEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XRANGE( + string key, + string start, + string end, + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XREVRANGE( + string key, + string end, + string start, + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREVRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XREAD( + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREAD"); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (block_milliseconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(block_milliseconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", streams); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XGROUP( + // Redis type: key + string create_key = "", + string create_groupname = "", + string create_id_or__ = "", + // Redis type: key + string setid_key = "", + string setid_groupname = "", + string setid_id_or__ = "", + // Redis type: key + string destroy_key = "", + string destroy_groupname = "", + // Redis type: key + string delconsumer_key = "", + string delconsumer_groupname = "", + string delconsumer_consumername = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XGROUP"); + if (create_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_key); + if (create_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_groupname); + if (create_id_or__ != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_id_or__); + if (setid_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_key); + if (setid_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_groupname); + if (setid_id_or__ != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_id_or__); + if (destroy_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", destroy_key); + if (destroy_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", destroy_groupname); + if (delconsumer_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_key); + if (delconsumer_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_groupname); + if (delconsumer_consumername != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_consumername); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XREADGROUP( + string group_group, + string group_consumer, + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string noack = "", + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREADGROUP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group_group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group_consumer); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (block_milliseconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(block_milliseconds)); + if (noack != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", noack); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", streams); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XACK( + string key, + string group, + string ID +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XACK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XCLAIM( + string key, + string group, + string consumer, + string min_idle_time, + string ID, + // Redis type: integer + int idle_ms = 0, + // Redis type: integer + int time_ms_unix_time = 0, + // Redis type: integer + int retrycount_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XCLAIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumer); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min_idle_time); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + if (idle_ms != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(idle_ms)); + if (time_ms_unix_time != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(time_ms_unix_time)); + if (retrycount_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(retrycount_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int NWNX_Redis_XPENDING( + string key, + string group, + string start = "", + string end = "", + // Redis type: integer + int count = 0, + string consumer = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XPENDING"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + if (start != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + if (end != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + if (consumer != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumer); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +/// @} diff --git a/nwnds_module/nwnx_redis_lib.nss b/nwnds_module/nwnx_redis_lib.nss new file mode 100644 index 000000000..759c61e1e --- /dev/null +++ b/nwnds_module/nwnx_redis_lib.nss @@ -0,0 +1,108 @@ +/// @addtogroup redis Redis +/// @brief Allows connection and interfacing with a redis server. +/// @{ +/// @file nwnx_redis_lib.nss +/// @brief Allows connection and interfacing with a redis server. +#include "nwnx" + +/// @anchor redis_results +/// @name Redis Results +/// @{ + +/// @brief Array result +const int NWNX_REDIS_RESULT_ARRAY = 1; + +/// This never appears: it is rewritten into STRING for simplicity reasons. +/// const int NWNX_REDIS_RESULT_BULK_STRING = 2; + +/// @brief Error result +/// @note You can retrieve errors as strings. +const int NWNX_REDIS_RESULT_ERROR = 3; + +/// @brief Integer result +/// @warning This cannot represent integers above 32bit. +/// @remark Use NWNX_Redis_GetResultAsString() if you need the string representation. +const int NWNX_REDIS_RESULT_INTEGER = 4; + +/// @brief String result +const int NWNX_REDIS_RESULT_STRING = 5; + +/// @brief Null result +const int NWNX_REDIS_RESULT_NULL = 6; +/// @} + +/// Returns the result type as a int. +int NWNX_Redis_GetResultType(int resultId); + +/// @brief Gets the length of the given result. +/// @param resultId The result id. +/// @return The length or 0 if the given result wasn't a list type. +int NWNX_Redis_GetArrayLength(int resultId); + +/// @brief Gets a list entry as a string. +/// @param resultId The result id. +/// @param idx The index in the list. +/// @return The list entry, will return "" if the given result is not a list, +/// or if the requested index is out of bounds. +int NWNX_Redis_GetArrayElement(int resultId, int idx); + +/// @brief Gets the given result as a float. +/// @param resultId The result id. +/// @return The result as a float. +float NWNX_Redis_GetResultAsFloat(int resultId); + +/// @brief Gets the given result as an integer. +/// @param resultId The result id. +/// @return The result as an integer. +int NWNX_Redis_GetResultAsInt(int resultId); + +/// @brief Gets the given result as a string. +/// @param resultId The result id. +/// @return The result as a string. +string NWNX_Redis_GetResultAsString(int resultId); + +/// @} + +int NWNX_Redis_GetResultType(int resultId) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultType", resultId); + NWNX_CallFunction("NWNX_Redis", "GetResultType"); + return NWNX_GetReturnValueInt("NWNX_Redis", "GetResultType"); +} + +int NWNX_Redis_GetArrayLength(int resultId) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultArrayLength", resultId); + NWNX_CallFunction("NWNX_Redis", "GetResultArrayLength"); + return NWNX_GetReturnValueInt("NWNX_Redis", "GetResultArrayLength"); +} + +// Returns the last +int NWNX_Redis_GetArrayElement(int resultId, int idx) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultArrayElement", resultId); + NWNX_PushArgumentInt("NWNX_Redis", "GetResultArrayElement", idx); + NWNX_CallFunction("NWNX_Redis", "GetResultArrayElement"); + return NWNX_GetReturnValueInt("NWNX_Redis", "GetResultArrayElement"); +} + +float NWNX_Redis_GetResultAsFloat(int resultId) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultAsString", resultId); + NWNX_CallFunction("NWNX_Redis", "GetResultAsString"); + return StringToFloat(NWNX_GetReturnValueString("NWNX_Redis", "GetResultAsString")); +} + +int NWNX_Redis_GetResultAsInt(int resultId) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultAsString", resultId); + NWNX_CallFunction("NWNX_Redis", "GetResultAsString"); + return StringToInt(NWNX_GetReturnValueString("NWNX_Redis", "GetResultAsString")); +} + +string NWNX_Redis_GetResultAsString(int resultId) +{ + NWNX_PushArgumentInt("NWNX_Redis", "GetResultAsString", resultId); + NWNX_CallFunction("NWNX_Redis", "GetResultAsString"); + return NWNX_GetReturnValueString("NWNX_Redis", "GetResultAsString"); +} diff --git a/nwnds_module/nwnx_redis_ps.nss b/nwnds_module/nwnx_redis_ps.nss new file mode 100644 index 000000000..1d59dd15d --- /dev/null +++ b/nwnds_module/nwnx_redis_ps.nss @@ -0,0 +1,23 @@ +/// @ingroup redis +/// @brief Interface to Redis PUBSUB +/// @{ +/// @file nwnx_redis_ps.nss +#include "nwnx" + +/// A redis PUBSUB message +struct NWNX_Redis_PubSubMessageData { + string channel; ///< The channel + string message; ///< The message +}; + +/// @brief Get a PUBSUB message +/// @return A NWNX_Redis_PubSubMessageData struct. +struct NWNX_Redis_PubSubMessageData NWNX_Redis_GetPubSubMessageData() +{ + struct NWNX_Redis_PubSubMessageData ret; + NWNX_CallFunction("NWNX_Redis", "GetPubSubData"); + ret.message = NWNX_GetReturnValueString("NWNX_Redis", "GetPubSubData"); + ret.channel = NWNX_GetReturnValueString("NWNX_Redis", "GetPubSubData"); + return ret; +} +/// @} diff --git a/nwnds_module/nwnx_redis_short.nss b/nwnds_module/nwnx_redis_short.nss new file mode 100644 index 000000000..c8adc656f --- /dev/null +++ b/nwnds_module/nwnx_redis_short.nss @@ -0,0 +1,5900 @@ +#include "nwnx" +#include "nwnx_redis_lib" + + +// Skipping sub-command: BITFIELD/{"command"=>"OVERFLOW", "type"=>"enum", "enum"=>["WRAP", "SAT", "FAIL"], "optional"=>true} - not supported yet. +// Skipping sub-command: CLIENT_KILL/{"command"=>"TYPE", "type"=>"enum", "enum"=>["normal", "master", "slave", "pubsub"], "optional"=>true} - not supported yet. +// Skipping sub-command: CLIENT_LIST/{"command"=>"TYPE", "type"=>"enum", "enum"=>["normal", "master", "replica", "pubsub"], "optional"=>true} - not supported yet. +// Skipping sub-command: SET/{"command"=>"expiration", "type"=>"enum", "enum"=>["EX seconds", "PX milliseconds"], "optional"=>true} - not supported yet. +// Skipping XCLAIM, cannot parse argument: {"name"=>"force", "enum"=>["FORCE"], "optional"=>true} - not supported yet. +// Skipping XCLAIM, cannot parse argument: {"name"=>"justid", "enum"=>["JUSTID"], "optional"=>true} - not supported yet. +/** + * APPEND + * + * Append a value to a key + * + * Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is + * small and the already present value is of any size, since the dynamic string + * library used by Redis will double the free space available on every + * reallocation. + * Annotated return value: integer + */ +int APPEND( + string key, + string value +); + +/** + * AUTH + * + * Authenticate to the server + * Annotated return value: simple-string + */ +int AUTH( + string password +); + +/** + * BGREWRITEAOF + * + * Asynchronously rewrite the append-only file + * Annotated return value: simple-string + */ +int BGREWRITEAOF(); + +/** + * BGSAVE + * + * Asynchronously save the dataset to disk + * Annotated return value: simple-string + */ +int BGSAVE(); + +/** + * BITCOUNT + * + * Count set bits in a string + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int BITCOUNT( + string key, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +); + +/** + * BITFIELD + * + * Perform arbitrary bitfield integer operations on strings + * + * Time complexity: O(1) for each subcommand specified + * Annotated return value: + */ +int BITFIELD( + string key, + // Redis type: type + string get_type = "", + // Redis type: integer + int get_offset = 0, + // Redis type: type + string set_type = "", + // Redis type: integer + int set_offset = 0, + // Redis type: integer + int set_value = 0, + // Redis type: type + string incrby_type = "", + // Redis type: integer + int incrby_offset = 0, + // Redis type: integer + int incrby_increment = 0 +); + +/** + * BITOP + * + * Perform bitwise operations between strings + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int BITOP( + string operation, + // Redis type: key + string destkey, + string key +); + +/** + * BITPOS + * + * Find first bit set or clear in a string + * + * Time complexity: O(N) + * Annotated return value: integer + */ +int BITPOS( + string key, + // Redis type: integer + int bit, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +); + +/** + * BLPOP + * + * Remove and get the first element in a list, or block until one is available + * + * Time complexity: O(1) + * Annotated return value: array + */ +int BLPOP( + string key, + // Redis type: integer + int timeout +); + +/** + * BRPOP + * + * Remove and get the last element in a list, or block until one is available + * + * Time complexity: O(1) + * Annotated return value: array + */ +int BRPOP( + string key, + // Redis type: integer + int timeout +); + +/** + * BRPOPLPUSH + * + * Pop a value from a list, push it to another list and return it; or block until one is available + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int BRPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination, + // Redis type: integer + int timeout +); + +/** + * BZPOPMIN + * + * Remove and return the member with the lowest score from one or more sorted sets, or block until one is available + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: array + */ +int BZPOPMIN( + string key, + // Redis type: integer + int timeout +); + +/** + * BZPOPMAX + * + * Remove and return the member with the highest score from one or more sorted sets, or block until one is available + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: array + */ +int BZPOPMAX( + string key, + // Redis type: integer + int timeout +); + +/** + * CLIENT_ID + * + * Returns the client ID for the current connection + * + * Time complexity: O(1) + * Annotated return value: + */ +int CLIENT_ID(); + +/** + * CLIENT_KILL + * + * Kill the connection of a client + * + * Time complexity: O(N) where N is the number of client connections + * Annotated return value: simple-string + */ +int CLIENT_KILL( + string ip_port = "", + // Redis type: integer + int id_client_id = 0, + string addr_ip_port = "", + string skipme_yes_no = "" +); + +/** + * CLIENT_LIST + * + * Get the list of client connections + * + * Time complexity: O(N) where N is the number of client connections + * Annotated return value: bulk-string + */ +int CLIENT_LIST(); + +/** + * CLIENT_GETNAME + * + * Get the current connection name + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int CLIENT_GETNAME(); + +/** + * CLIENT_PAUSE + * + * Stop processing commands from clients for some time + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLIENT_PAUSE( + // Redis type: integer + int timeout +); + +/** + * CLIENT_REPLY + * + * Instruct the server whether to reply to commands + * + * Time complexity: O(1) + + * - Valid values for reply_mode: "ON", "OFF", "SKIP" + * Annotated return value: simple-string + */ +int CLIENT_REPLY( + // Redis type: enum + string reply_mode +); + +/** + * CLIENT_SETNAME + * + * Set the current connection name + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLIENT_SETNAME( + string connection_name +); + +/** + * CLIENT_UNBLOCK + * + * Unblock a client blocked in a blocking command from a different connection + * + * Time complexity: O(log N) where N is the number of client connections + + * - Valid values for unblock_type: "TIMEOUT", "ERROR" + * Annotated return value: + */ +int CLIENT_UNBLOCK( + string client_id, + // Redis type: enum + string unblock_type = "" +); + +/** + * CLUSTER_ADDSLOTS + * + * Assign new hash slots to receiving node + * + * Time complexity: O(N) where N is the total number of hash slot arguments + * Annotated return value: simple-string + */ +int CLUSTER_ADDSLOTS( + // Redis type: integer + int slot +); + +/** + * CLUSTER_COUNT_FAILURE_REPORTS + * + * Return the number of failure reports active for a given node + * + * Time complexity: O(N) where N is the number of failure reports + * Annotated return value: integer + */ +int CLUSTER_COUNT_FAILURE_REPORTS( + string node_id +); + +/** + * CLUSTER_COUNTKEYSINSLOT + * + * Return the number of local keys in the specified hash slot + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int CLUSTER_COUNTKEYSINSLOT( + // Redis type: integer + int slot +); + +/** + * CLUSTER_DELSLOTS + * + * Set hash slots as unbound in receiving node + * + * Time complexity: O(N) where N is the total number of hash slot arguments + * Annotated return value: simple-string + */ +int CLUSTER_DELSLOTS( + // Redis type: integer + int slot +); + +/** + * CLUSTER_FAILOVER + * + * Forces a replica to perform a manual failover of its master. + * + * Time complexity: O(1) + + * - Valid values for options: "FORCE", "TAKEOVER" + * Annotated return value: simple-string + */ +int CLUSTER_FAILOVER( + // Redis type: enum + string options = "" +); + +/** + * CLUSTER_FORGET + * + * Remove a node from the nodes table + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLUSTER_FORGET( + string node_id +); + +/** + * CLUSTER_GETKEYSINSLOT + * + * Return local key names in the specified hash slot + * + * Time complexity: O(log(N)) where N is the number of requested keys + * Annotated return value: array + */ +int CLUSTER_GETKEYSINSLOT( + // Redis type: integer + int slot, + // Redis type: integer + int count +); + +/** + * CLUSTER_INFO + * + * Provides info about Redis Cluster node state + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int CLUSTER_INFO(); + +/** + * CLUSTER_KEYSLOT + * + * Returns the hash slot of the specified key + * + * Time complexity: O(N) where N is the number of bytes in the key + * Annotated return value: integer + */ +int CLUSTER_KEYSLOT( + string key +); + +/** + * CLUSTER_MEET + * + * Force a node cluster to handshake with another node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLUSTER_MEET( + string ip, + // Redis type: integer + int port +); + +/** + * CLUSTER_NODES + * + * Get Cluster config for the node + * + * Time complexity: O(N) where N is the total number of Cluster nodes + * Annotated return value: bulk-string + */ +int CLUSTER_NODES(); + +/** + * CLUSTER_REPLICATE + * + * Reconfigure a node as a replica of the specified master node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLUSTER_REPLICATE( + string node_id +); + +/** + * CLUSTER_RESET + * + * Reset a Redis Cluster node + * + * Time complexity: O(N) where N is the number of known nodes. The command may execute a + * FLUSHALL as a side effect. + + * - Valid values for reset_type: "HARD", "SOFT" + * Annotated return value: simple-string + */ +int CLUSTER_RESET( + // Redis type: enum + string reset_type = "" +); + +/** + * CLUSTER_SAVECONFIG + * + * Forces the node to save cluster state on disk + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLUSTER_SAVECONFIG(); + +/** + * CLUSTER_SET_CONFIG_EPOCH + * + * Set the configuration epoch in a new node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CLUSTER_SET_CONFIG_EPOCH( + // Redis type: integer + int config_epoch +); + +/** + * CLUSTER_SETSLOT + * + * Bind a hash slot to a specific node + * + * Time complexity: O(1) + + * - Valid values for subcommand: "IMPORTING", "MIGRATING", "STABLE", "NODE" + * Annotated return value: simple-string + */ +int CLUSTER_SETSLOT( + // Redis type: integer + int slot, + // Redis type: enum + string subcommand, + string node_id = "" +); + +/** + * CLUSTER_SLAVES + * + * List replica nodes of the specified master node + * + * Time complexity: O(1) + * Annotated return value: + */ +int CLUSTER_SLAVES( + string node_id +); + +/** + * CLUSTER_REPLICAS + * + * List replica nodes of the specified master node + * + * Time complexity: O(1) + * Annotated return value: + */ +int CLUSTER_REPLICAS( + string node_id +); + +/** + * CLUSTER_SLOTS + * + * Get array of Cluster slot to node mappings + * + * Time complexity: O(N) where N is the total number of Cluster nodes + * Annotated return value: array + */ +int CLUSTER_SLOTS(); + +/** + * COMMAND + * + * Get array of Redis command details + * + * Time complexity: O(N) where N is the total number of Redis commands + * Annotated return value: array + */ +int COMMAND(); + +/** + * COMMAND_COUNT + * + * Get total number of Redis commands + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int COMMAND_COUNT(); + +/** + * COMMAND_GETKEYS + * + * Extract keys given a full Redis command + * + * Time complexity: O(N) where N is the number of arguments to the command + * Annotated return value: array + */ +int COMMAND_GETKEYS(); + +/** + * COMMAND_INFO + * + * Get array of specific Redis command details + * + * Time complexity: O(N) when N is number of commands to look up + * Annotated return value: array + */ +int COMMAND_INFO( + string command_name +); + +/** + * CONFIG_GET + * + * Get the value of a configuration parameter + * Annotated return value: array + */ +int CONFIG_GET( + string parameter +); + +/** + * CONFIG_REWRITE + * + * Rewrite the configuration file with the in memory configuration + * Annotated return value: simple-string + */ +int CONFIG_REWRITE(); + +/** + * CONFIG_SET + * + * Set a configuration parameter to the given value + * Annotated return value: simple-string + */ +int CONFIG_SET( + string parameter, + string value +); + +/** + * CONFIG_RESETSTAT + * + * Reset the stats returned by INFO + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int CONFIG_RESETSTAT(); + +/** + * DBSIZE + * + * Return the number of keys in the selected database + * Annotated return value: integer + */ +int DBSIZE(); + +/** + * DEBUG_OBJECT + * + * Get debugging information about a key + * Annotated return value: simple-string + */ +int DEBUG_OBJECT( + string key +); + +/** + * DEBUG_SEGFAULT + * + * Make the server crash + * Annotated return value: simple-string + */ +int DEBUG_SEGFAULT(); + +/** + * DECR + * + * Decrement the integer value of a key by one + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int DECR( + string key +); + +/** + * DECRBY + * + * Decrement the integer value of a key by the given number + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int DECRBY( + string key, + // Redis type: integer + int decrement +); + +/** + * DEL + * + * Delete a key + * + * Time complexity: O(N) where N is the number of keys that will be removed. When a key to + * remove holds a value other than a string, the individual complexity for this + * key is O(M) where M is the number of elements in the list, set, sorted set + * or hash. Removing a single key that holds a string value is O(1). + * Annotated return value: integer + */ +int DEL( + string key +); + +/** + * DISCARD + * + * Discard all commands issued after MULTI + * Annotated return value: simple-string + */ +int DISCARD(); + +/** + * DUMP + * + * Return a serialized version of the value stored at the specified key. + * + * Time complexity: O(1) to access the key and additional O(N*M) to serialized it, where N is + * the number of Redis objects composing the value and M their average size. + * For small string values the time complexity is thus O(1)+O(1*M) where M is + * small, so simply O(1). + * Annotated return value: bulk-string + */ +int DUMP( + string key +); + +/** + * ECHO + * + * Echo the given string + * Annotated return value: bulk-string + */ +int ECHO( + string message +); + +/** + * EVAL + * + * Execute a Lua script server side + * + * Time complexity: Depends on the script that is executed. + * Annotated return value: + */ +int EVAL( + string script, + // Redis type: integer + int numkeys, + string key, + string arg +); + +/** + * EVALSHA + * + * Execute a Lua script server side + * + * Time complexity: Depends on the script that is executed. + * Annotated return value: + */ +int EVALSHA( + string sha1, + // Redis type: integer + int numkeys, + string key, + string arg +); + +/** + * EXEC + * + * Execute all commands issued after MULTI + * Annotated return value: array + */ +int EXEC(); + +/** + * EXISTS + * + * Determine if a key exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int EXISTS( + string key +); + +/** + * EXPIRE + * + * Set a key's time to live in seconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int EXPIRE( + string key, + // Redis type: integer + int seconds +); + +/** + * EXPIREAT + * + * Set the expiration for a key as a UNIX timestamp + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int EXPIREAT( + string key, + // Redis type: posix time + string timestamp +); + +/** + * FLUSHALL + * + * Remove all keys from all databases + + * - Valid values for async: "ASYNC" + * Annotated return value: simple-string + */ +int FLUSHALL( + // Redis type: enum + string async = "" +); + +/** + * FLUSHDB + * + * Remove all keys from the current database + + * - Valid values for async: "ASYNC" + * Annotated return value: simple-string + */ +int FLUSHDB( + // Redis type: enum + string async = "" +); + +/** + * GEOADD + * + * Add one or more geospatial items in the geospatial index represented using a sorted set + * + * Time complexity: O(log(N)) for each item added, where N is the number of elements in the + * sorted set. + * Annotated return value: integer + */ +int GEOADD( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + string member +); + +/** + * GEOHASH + * + * Returns members of a geospatial index as standard geohash strings + * + * Time complexity: O(log(N)) for each member requested, where N is the number of elements in + * the sorted set. + * Annotated return value: array + */ +int GEOHASH( + string key, + string member +); + +/** + * GEOPOS + * + * Returns longitude and latitude of members of a geospatial index + * + * Time complexity: O(log(N)) for each member requested, where N is the number of elements in + * the sorted set. + * Annotated return value: array + */ +int GEOPOS( + string key, + string member +); + +/** + * GEODIST + * + * Returns the distance between two members of a geospatial index + * + * Time complexity: O(log(N)) + * Annotated return value: bulk-string + */ +int GEODIST( + string key, + string member1, + string member2, + string unit = "" +); + +/** + * GEORADIUS + * + * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point + * + * Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the + * circular area delimited by center and radius and M is the number of items + * inside the index. + + * - Valid values for unit: "m", "km", "ft", "mi" + + * - Valid values for withcoord: "WITHCOORD" + + * - Valid values for withdist: "WITHDIST" + + * - Valid values for withhash: "WITHHASH" + + * - Valid values for order: "ASC", "DESC" + * Annotated return value: array + */ +int GEORADIUS( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +); + +/** + * GEORADIUSBYMEMBER + * + * Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member + * + * Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the + * circular area delimited by center and radius and M is the number of items + * inside the index. + + * - Valid values for unit: "m", "km", "ft", "mi" + + * - Valid values for withcoord: "WITHCOORD" + + * - Valid values for withdist: "WITHDIST" + + * - Valid values for withhash: "WITHHASH" + + * - Valid values for order: "ASC", "DESC" + * Annotated return value: + */ +int GEORADIUSBYMEMBER( + string key, + string member, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +); + +/** + * GET + * + * Get the value of a key + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int GET( + string key +); + +/** + * GETBIT + * + * Returns the bit value at offset in the string value stored at key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int GETBIT( + string key, + // Redis type: integer + int offset +); + +/** + * GETRANGE + * + * Get a substring of the string stored at a key + * + * Time complexity: O(N) where N is the length of the returned string. The complexity is + * ultimately determined by the returned length, but because creating a + * substring from an existing string is very cheap, it can be considered O(1) + * for small strings. + * Annotated return value: bulk-string + */ +int GETRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int end +); + +/** + * GETSET + * + * Set the string value of a key and return its old value + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int GETSET( + string key, + string value +); + +/** + * HDEL + * + * Delete one or more hash fields + * + * Time complexity: O(N) where N is the number of fields to be removed. + * Annotated return value: integer + */ +int HDEL( + string key, + string field +); + +/** + * HEXISTS + * + * Determine if a hash field exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HEXISTS( + string key, + string field +); + +/** + * HGET + * + * Get the value of a hash field + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int HGET( + string key, + string field +); + +/** + * HGETALL + * + * Get all the fields and values in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int HGETALL( + string key +); + +/** + * HINCRBY + * + * Increment the integer value of a hash field by the given number + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HINCRBY( + string key, + string field, + // Redis type: integer + int increment +); + +/** + * HINCRBYFLOAT + * + * Increment the float value of a hash field by the given amount + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int HINCRBYFLOAT( + string key, + string field, + // Redis type: double + float increment +); + +/** + * HKEYS + * + * Get all the fields in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int HKEYS( + string key +); + +/** + * HLEN + * + * Get the number of fields in a hash + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HLEN( + string key +); + +/** + * HMGET + * + * Get the values of all the given hash fields + * + * Time complexity: O(N) where N is the number of fields being requested. + * Annotated return value: array + */ +int HMGET( + string key, + string field +); + +/** + * HMSET + * + * Set multiple hash fields to multiple values + * + * Time complexity: O(N) where N is the number of fields being set. + * Annotated return value: simple-string + */ +int HMSET( + string key, + string field, + string value +); + +/** + * HSET + * + * Set the string value of a hash field + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HSET( + string key, + string field, + string value +); + +/** + * HSETNX + * + * Set the value of a hash field, only if the field does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HSETNX( + string key, + string field, + string value +); + +/** + * HSTRLEN + * + * Get the length of the value of a hash field + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int HSTRLEN( + string key, + string field +); + +/** + * HVALS + * + * Get all the values in a hash + * + * Time complexity: O(N) where N is the size of the hash. + * Annotated return value: array + */ +int HVALS( + string key +); + +/** + * INCR + * + * Increment the integer value of a key by one + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int INCR( + string key +); + +/** + * INCRBY + * + * Increment the integer value of a key by the given amount + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int INCRBY( + string key, + // Redis type: integer + int increment +); + +/** + * INCRBYFLOAT + * + * Increment the float value of a key by the given amount + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int INCRBYFLOAT( + string key, + // Redis type: double + float increment +); + +/** + * INFO + * + * Get information and statistics about the server + * Annotated return value: bulk-string + */ +int INFO( + string section = "" +); + +/** + * KEYS + * + * Find all keys matching the given pattern + * + * Time complexity: O(N) with N being the number of keys in the database, under the assumption + * that the key names in the database and the given pattern have limited + * length. + * Annotated return value: array + */ +int KEYS( + string pattern +); + +/** + * LASTSAVE + * + * Get the UNIX time stamp of the last successful save to disk + * Annotated return value: integer + */ +int LASTSAVE(); + +/** + * LINDEX + * + * Get an element from a list by its index + * + * Time complexity: O(N) where N is the number of elements to traverse to get to the element at + * index. This makes asking for the first or the last element of the list O(1). + * Annotated return value: bulk-string + */ +int LINDEX( + string key, + // Redis type: integer + int index +); + +/** + * LINSERT + * + * Insert an element before or after another element in a list + * + * Time complexity: O(N) where N is the number of elements to traverse before seeing the value + * pivot. This means that inserting somewhere on the left end on the list + * (head) can be considered O(1) and inserting somewhere on the right end + * (tail) is O(N). + + * - Valid values for where: "BEFORE", "AFTER" + * Annotated return value: integer + */ +int LINSERT( + string key, + // Redis type: enum + string where, + string pivot, + string value +); + +/** + * LLEN + * + * Get the length of a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int LLEN( + string key +); + +/** + * LPOP + * + * Remove and get the first element in a list + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int LPOP( + string key +); + +/** + * LPUSH + * + * Prepend one or multiple values to a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int LPUSH( + string key, + string value +); + +/** + * LPUSHX + * + * Prepend a value to a list, only if the list exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int LPUSHX( + string key, + string value +); + +/** + * LRANGE + * + * Get a range of elements from a list + * + * Time complexity: O(S+N) where S is the distance of start offset from HEAD for small lists, + * from nearest end (HEAD or TAIL) for large lists; and N is the number of + * elements in the specified range. + * Annotated return value: array + */ +int LRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * LREM + * + * Remove elements from a list + * + * Time complexity: O(N) where N is the length of the list. + * Annotated return value: integer + */ +int LREM( + string key, + // Redis type: integer + int count, + string value +); + +/** + * LSET + * + * Set the value of an element in a list by its index + * + * Time complexity: O(N) where N is the length of the list. Setting either the first or the last + * element of the list is O(1). + * Annotated return value: simple-string + */ +int LSET( + string key, + // Redis type: integer + int index, + string value +); + +/** + * LTRIM + * + * Trim a list to the specified range + * + * Time complexity: O(N) where N is the number of elements to be removed by the operation. + * Annotated return value: simple-string + */ +int LTRIM( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * MEMORY_DOCTOR + * + * Outputs memory problems report + * Annotated return value: bulk-string + */ +int MEMORY_DOCTOR(); + +/** + * MEMORY_HELP + * + * Show helpful text about the different subcommands + * Annotated return value: array + */ +int MEMORY_HELP(); + +/** + * MEMORY_MALLOC_STATS + * + * Show allocator internal stats + * Annotated return value: bulk-string + */ +int MEMORY_MALLOC_STATS(); + +/** + * MEMORY_PURGE + * + * Ask the allocator to release memory + * Annotated return value: simple-string + */ +int MEMORY_PURGE(); + +/** + * MEMORY_STATS + * + * Show memory usage details + * Annotated return value: array + */ +int MEMORY_STATS(); + +/** + * MEMORY_USAGE + * + * Estimate the memory usage of a key + * + * Time complexity: O(N) where N is the number of samples. + * Annotated return value: integer + */ +int MEMORY_USAGE( + string key, + // Redis type: integer + int samples_count = 0 +); + +/** + * MGET + * + * Get the values of all the given keys + * + * Time complexity: O(N) where N is the number of keys to retrieve. + * Annotated return value: array + */ +int MGET( + string key +); + +/** + * MIGRATE + * + * Atomically transfer a key from a Redis instance to another one. + * + * Time complexity: This command actually executes a DUMP+DEL in the source instance, and a + * RESTORE in the target instance. See the pages of these commands for time + * complexity. Also an O(N) data transfer between the two instances is + * performed. + + * - Valid values for key: "key", "\"\"" + + * - Valid values for copy: "COPY" + + * - Valid values for replace: "REPLACE" + * Annotated return value: simple-string + */ +int MIGRATE( + string host, + string port, + // Redis type: enum + string key, + // Redis type: integer + int destination_db, + // Redis type: integer + int timeout, + // Redis type: enum + string copy = "", + // Redis type: enum + string replace = "", + string auth_password = "", + // Redis type: key + string keys_key = "" +); + +/** + * MONITOR + * + * Listen for all requests received by the server in real time + * Annotated return value: + */ +int MONITOR(); + +/** + * MOVE + * + * Move a key to another database + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int MOVE( + string key, + // Redis type: integer + int db +); + +/** + * MSET + * + * Set multiple keys to multiple values + * + * Time complexity: O(N) where N is the number of keys to set. + * Annotated return value: simple-string + */ +int MSET( + string key, + string value +); + +/** + * MSETNX + * + * Set multiple keys to multiple values, only if none of the keys exist + * + * Time complexity: O(N) where N is the number of keys to set. + * Annotated return value: integer + */ +int MSETNX( + string key, + string value +); + +/** + * MULTI + * + * Mark the start of a transaction block + * Annotated return value: simple-string + */ +int MULTI(); + +/** + * OBJECT + * + * Inspect the internals of Redis objects + * + * Time complexity: O(1) for all the currently implemented subcommands. + * Annotated return value: + */ +int OBJECT( + string subcommand, + string arguments = "" +); + +/** + * PERSIST + * + * Remove the expiration from a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int PERSIST( + string key +); + +/** + * PEXPIRE + * + * Set a key's time to live in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int PEXPIRE( + string key, + // Redis type: integer + int milliseconds +); + +/** + * PEXPIREAT + * + * Set the expiration for a key as a UNIX timestamp specified in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int PEXPIREAT( + string key, + // Redis type: posix time + string milliseconds_timestamp +); + +/** + * PFADD + * + * Adds the specified elements to the specified HyperLogLog. + * + * Time complexity: O(1) to add every element. + * Annotated return value: integer + */ +int PFADD( + string key, + string element +); + +/** + * PFCOUNT + * + * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). + * + * Time complexity: O(1) with a very small average constant time when called with a single key. + * O(N) with N being the number of keys, and much bigger constant times, when + * called with multiple keys. + * Annotated return value: integer + */ +int PFCOUNT( + string key +); + +/** + * PFMERGE + * + * Merge N different HyperLogLogs into a single one. + * + * Time complexity: O(N) to merge N HyperLogLogs, but with high constant times. + * Annotated return value: simple-string + */ +int PFMERGE( + // Redis type: key + string destkey, + // Redis type: key + string sourcekey +); + +/** + * PING + * + * Ping the server + * Annotated return value: simple-string + */ +int PING( + string message = "" +); + +/** + * PSETEX + * + * Set the value and expiration in milliseconds of a key + * + * Time complexity: O(1) + * Annotated return value: + */ +int PSETEX( + string key, + // Redis type: integer + int milliseconds, + string value +); + +/** + * PUBSUB + * + * Inspect the state of the Pub/Sub subsystem + * + * Time complexity: O(N) for the CHANNELS subcommand, where N is the number of active channels, + * and assuming constant time pattern matching (relatively short channels and + * patterns). O(N) for the NUMSUB subcommand, where N is the number of + * requested channels. O(1) for the NUMPAT subcommand. + * Annotated return value: array + */ +int PUBSUB( + string subcommand, + string argument = "" +); + +/** + * PTTL + * + * Get the time to live for a key in milliseconds + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int PTTL( + string key +); + +/** + * PUBLISH + * + * Post a message to a channel + * + * Time complexity: O(N+M) where N is the number of clients subscribed to the receiving channel + * and M is the total number of subscribed patterns (by any client). + * Annotated return value: integer + */ +int PUBLISH( + string channel, + string message +); + +/** + * QUIT + * + * Close the connection + * Annotated return value: simple-string + */ +int QUIT(); + +/** + * RANDOMKEY + * + * Return a random key from the keyspace + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int RANDOMKEY(); + +/** + * READONLY + * + * Enables read queries for a connection to a cluster replica node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int READONLY(); + +/** + * READWRITE + * + * Disables read queries for a connection to a cluster replica node + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int READWRITE(); + +/** + * RENAME + * + * Rename a key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int RENAME( + string key, + // Redis type: key + string newkey +); + +/** + * RENAMENX + * + * Rename a key, only if the new key does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int RENAMENX( + string key, + // Redis type: key + string newkey +); + +/** + * RESTORE + * + * Create a key using the provided serialized value, previously obtained using DUMP. + * + * Time complexity: O(1) to create the new key and additional O(N*M) to reconstruct the + * serialized value, where N is the number of Redis objects composing the value + * and M their average size. For small string values the time complexity is + * thus O(1)+O(1*M) where M is small, so simply O(1). However for sorted set + * values the complexity is O(N*M*log(N)) because inserting values into sorted + * sets is O(log(N)). + + * - Valid values for replace: "REPLACE" + + * - Valid values for absttl: "ABSTTL" + * Annotated return value: simple-string + */ +int RESTORE( + string key, + // Redis type: integer + int ttl, + string serialized_value, + // Redis type: enum + string replace = "", + // Redis type: enum + string absttl = "", + // Redis type: integer + int idletime_seconds = 0, + // Redis type: integer + int freq_frequency = 0 +); + +/** + * ROLE + * + * Return the role of the instance in the context of replication + * Annotated return value: array + */ +int ROLE(); + +/** + * RPOP + * + * Remove and get the last element in a list + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int RPOP( + string key +); + +/** + * RPOPLPUSH + * + * Remove the last element in a list, prepend it to another list and return it + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int RPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination +); + +/** + * RPUSH + * + * Append one or multiple values to a list + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int RPUSH( + string key, + string value +); + +/** + * RPUSHX + * + * Append a value to a list, only if the list exists + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int RPUSHX( + string key, + string value +); + +/** + * SADD + * + * Add one or more members to a set + * + * Time complexity: O(1) for each element added, so O(N) to add N elements when the command is + * called with multiple arguments. + * Annotated return value: integer + */ +int SADD( + string key, + string member +); + +/** + * SAVE + * + * Synchronously save the dataset to disk + * Annotated return value: simple-string + */ +int SAVE(); + +/** + * SCARD + * + * Get the number of members in a set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int SCARD( + string key +); + +/** + * SCRIPT_DEBUG + * + * Set the debug mode for executed scripts. + * + * Time complexity: O(1) + + * - Valid values for mode: "YES", "SYNC", "NO" + * Annotated return value: simple-string + */ +int SCRIPT_DEBUG( + // Redis type: enum + string mode +); + +/** + * SCRIPT_EXISTS + * + * Check existence of scripts in the script cache. + * + * Time complexity: O(N) with N being the number of scripts to check (so checking a single + * script is an O(1) operation). + * Annotated return value: array + */ +int SCRIPT_EXISTS( + string sha1 +); + +/** + * SCRIPT_FLUSH + * + * Remove all the scripts from the script cache. + * + * Time complexity: O(N) with N being the number of scripts in cache + * Annotated return value: simple-string + */ +int SCRIPT_FLUSH(); + +/** + * SCRIPT_KILL + * + * Kill the script currently in execution. + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int SCRIPT_KILL(); + +/** + * SCRIPT_LOAD + * + * Load the specified Lua script into the script cache. + * + * Time complexity: O(N) with N being the length in bytes of the script body. + * Annotated return value: bulk-string + */ +int SCRIPT_LOAD( + string script +); + +/** + * SDIFF + * + * Subtract multiple sets + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: array + */ +int SDIFF( + string key +); + +/** + * SDIFFSTORE + * + * Subtract multiple sets and store the resulting set in a key + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: integer + */ +int SDIFFSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SELECT + * + * Change the selected database for the current connection + * Annotated return value: simple-string + */ +int SELECT( + // Redis type: integer + int index +); + +/** + * SET + * + * Set the string value of a key + * + * Time complexity: O(1) + + * - Valid values for condition: "NX", "XX" + * Annotated return value: simple-string + */ +int SET( + string key, + string value, + // Redis type: enum + string condition = "" +); + +/** + * SETBIT + * + * Sets or clears the bit at offset in the string value stored at key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int SETBIT( + string key, + // Redis type: integer + int offset, + string value +); + +/** + * SETEX + * + * Set the value and expiration of a key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int SETEX( + string key, + // Redis type: integer + int seconds, + string value +); + +/** + * SETNX + * + * Set the value of a key, only if the key does not exist + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int SETNX( + string key, + string value +); + +/** + * SETRANGE + * + * Overwrite part of a string at key starting at the specified offset + * + * Time complexity: O(1), not counting the time taken to copy the new string in place. Usually, + * this string is very small so the amortized complexity is O(1). Otherwise, + * complexity is O(M) with M being the length of the value argument. + * Annotated return value: integer + */ +int SETRANGE( + string key, + // Redis type: integer + int offset, + string value +); + +/** + * SHUTDOWN + * + * Synchronously save the dataset to disk and then shut down the server + + * - Valid values for save_mode: "NOSAVE", "SAVE" + * Annotated return value: simple-string + */ +int SHUTDOWN( + // Redis type: enum + string save_mode = "" +); + +/** + * SINTER + * + * Intersect multiple sets + * + * Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is + * the number of sets. + * Annotated return value: array + */ +int SINTER( + string key +); + +/** + * SINTERSTORE + * + * Intersect multiple sets and store the resulting set in a key + * + * Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is + * the number of sets. + * Annotated return value: integer + */ +int SINTERSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SISMEMBER + * + * Determine if a given value is a member of a set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int SISMEMBER( + string key, + string member +); + +/** + * SLAVEOF + * + * Make the server a replica of another instance, or promote it as master. Deprecated starting with Redis 5. Use REPLICAOF instead. + * Annotated return value: simple-string + */ +int SLAVEOF( + string host, + string port +); + +/** + * REPLICAOF + * + * Make the server a replica of another instance, or promote it as master. + * Annotated return value: simple-string + */ +int REPLICAOF( + string host, + string port +); + +/** + * SLOWLOG + * + * Manages the Redis slow queries log + * Annotated return value: + */ +int SLOWLOG( + string subcommand, + string argument = "" +); + +/** + * SMEMBERS + * + * Get all the members in a set + * + * Time complexity: O(N) where N is the set cardinality. + * Annotated return value: array + */ +int SMEMBERS( + string key +); + +/** + * SMOVE + * + * Move a member from one set to another + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int SMOVE( + // Redis type: key + string source, + // Redis type: key + string destination, + string member +); + +/** + * SORT + * + * Sort the elements in a list, set or sorted set + * + * Time complexity: O(N+M*log(M)) where N is the number of elements in the list or set to sort, + * and M the number of returned elements. When the elements are not sorted, + * complexity is currently O(N) as there is a copy step that will be avoided in + * next releases. + + * - Valid values for order: "ASC", "DESC" + + * - Valid values for sorting: "ALPHA" + * Annotated return value: array + */ +int SORT( + string key, + // Redis type: pattern + string by_pattern = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0, + string get_pattern = "", + // Redis type: enum + string order = "", + // Redis type: enum + string sorting = "", + // Redis type: key + string store_destination = "" +); + +/** + * SPOP + * + * Remove and return one or multiple random members from a set + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int SPOP( + string key, + // Redis type: integer + int count = 0 +); + +/** + * SRANDMEMBER + * + * Get one or multiple random members from a set + * + * Time complexity: Without the count argument O(1), otherwise O(N) where N is the absolute + * value of the passed count. + * Annotated return value: bulk-string + */ +int SRANDMEMBER( + string key, + // Redis type: integer + int count = 0 +); + +/** + * SREM + * + * Remove one or more members from a set + * + * Time complexity: O(N) where N is the number of members to be removed. + * Annotated return value: integer + */ +int SREM( + string key, + string member +); + +/** + * STRLEN + * + * Get the length of the value stored in a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int STRLEN( + string key +); + +/** + * SUNION + * + * Add multiple sets + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: array + */ +int SUNION( + string key +); + +/** + * SUNIONSTORE + * + * Add multiple sets and store the resulting set in a key + * + * Time complexity: O(N) where N is the total number of elements in all given sets. + * Annotated return value: integer + */ +int SUNIONSTORE( + // Redis type: key + string destination, + string key +); + +/** + * SWAPDB + * + * Swaps two Redis databases + * Annotated return value: simple-string + */ +int SWAPDB( + // Redis type: integer + int index, + // Redis type: integer + int index_1 +); + +/** + * SYNC + * + * Internal command used for replication + * Annotated return value: + */ +int SYNC(); + +/** + * TIME + * + * Return the current server time + * + * Time complexity: O(1) + * Annotated return value: array + */ +int TIME(); + +/** + * TOUCH + * + * Alters the last access time of a key(s). Returns the number of existing keys specified. + * + * Time complexity: O(N) where N is the number of keys that will be touched. + * Annotated return value: integer + */ +int TOUCH( + string key +); + +/** + * TTL + * + * Get the time to live for a key + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int TTL( + string key +); + +/** + * TYPE + * + * Determine the type stored at key + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int TYPE( + string key +); + +/** + * UNLINK + * + * Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking. + * + * Time complexity: O(1) for each key removed regardless of its size. Then the command does O(N) + * work in a different thread in order to reclaim memory, where N is the number + * of allocations the deleted objects where composed of. + * Annotated return value: integer + */ +int UNLINK( + string key +); + +/** + * UNWATCH + * + * Forget about all watched keys + * + * Time complexity: O(1) + * Annotated return value: simple-string + */ +int UNWATCH(); + +/** + * WAIT + * + * Wait for the synchronous replication of all the write commands sent in the context of the current connection + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int WAIT( + // Redis type: integer + int numreplicas, + // Redis type: integer + int timeout +); + +/** + * WATCH + * + * Watch the given keys to determine execution of the MULTI/EXEC block + * + * Time complexity: O(1) for every key. + * Annotated return value: simple-string + */ +int WATCH( + string key +); + +/** + * ZADD + * + * Add one or more members to a sorted set, or update its score if it already exists + * + * Time complexity: O(log(N)) for each item added, where N is the number of elements in the + * sorted set. + + * - Valid values for condition: "NX", "XX" + + * - Valid values for change: "CH" + + * - Valid values for increment: "INCR" + * Annotated return value: integer + */ +int ZADD( + string key, + // Redis type: enum + string condition = "", + // Redis type: enum + string change = "", + // Redis type: enum + string increment = "", + // Redis type: double + float score = 0.0, + string member = "" +); + +/** + * ZCARD + * + * Get the number of members in a sorted set + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int ZCARD( + string key +); + +/** + * ZCOUNT + * + * Count the members in a sorted set with scores within the given values + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: integer + */ +int ZCOUNT( + string key, + // Redis type: double + float min, + // Redis type: double + float max +); + +/** + * ZINCRBY + * + * Increment the score of a member in a sorted set + * + * Time complexity: O(log(N)) where N is the number of elements in the sorted set. + * Annotated return value: bulk-string + */ +int ZINCRBY( + string key, + // Redis type: integer + int increment, + string member +); + +/** + * ZINTERSTORE + * + * Intersect multiple sorted sets and store the resulting sorted set in a new key + * + * Time complexity: O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K + * being the number of input sorted sets and M being the number of elements in + * the resulting sorted set. + + * - Valid values for aggregate_aggregate: "SUM", "MIN", "MAX" + * Annotated return value: integer + */ +int ZINTERSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +); + +/** + * ZLEXCOUNT + * + * Count the number of members in a sorted set between a given lexicographical range + * + * Time complexity: O(log(N)) with N being the number of elements in the sorted set. + * Annotated return value: integer + */ +int ZLEXCOUNT( + string key, + string min, + string max +); + +/** + * ZPOPMAX + * + * Remove and return members with the highest scores in a sorted set + * + * Time complexity: O(log(N)*M) with N being the number of elements in the sorted set, and M + * being the number of elements popped. + * Annotated return value: array + */ +int ZPOPMAX( + string key, + // Redis type: integer + int count = 0 +); + +/** + * ZPOPMIN + * + * Remove and return members with the lowest scores in a sorted set + * + * Time complexity: O(log(N)*M) with N being the number of elements in the sorted set, and M + * being the number of elements popped. + * Annotated return value: array + */ +int ZPOPMIN( + string key, + // Redis type: integer + int count = 0 +); + +/** + * ZRANGE + * + * Return a range of members in a sorted set, by index + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements returned. + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int ZRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +); + +/** + * ZRANGEBYLEX + * + * Return a range of members in a sorted set, by lexicographical range + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + * Annotated return value: array + */ +int ZRANGEBYLEX( + string key, + string min, + string max, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZREVRANGEBYLEX + * + * Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings. + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + * Annotated return value: array + */ +int ZREVRANGEBYLEX( + string key, + string max, + string min, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZRANGEBYSCORE + * + * Return a range of members in a sorted set, by score + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int ZRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZRANK + * + * Determine the index of a member in a sorted set + * + * Time complexity: O(log(N)) + * Annotated return value: integer + */ +int ZRANK( + string key, + string member +); + +/** + * ZREM + * + * Remove one or more members from a sorted set + * + * Time complexity: O(M*log(N)) with N being the number of elements in the sorted set and M the + * number of elements to be removed. + * Annotated return value: integer + */ +int ZREM( + string key, + string member +); + +/** + * ZREMRANGEBYLEX + * + * Remove all members in a sorted set between the given lexicographical range + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int ZREMRANGEBYLEX( + string key, + string min, + string max +); + +/** + * ZREMRANGEBYRANK + * + * Remove all members in a sorted set within the given indexes + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int ZREMRANGEBYRANK( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +); + +/** + * ZREMRANGEBYSCORE + * + * Remove all members in a sorted set within the given scores + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements removed by the operation. + * Annotated return value: integer + */ +int ZREMRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max +); + +/** + * ZREVRANGE + * + * Return a range of members in a sorted set, by index, with scores ordered from high to low + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements returned. + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int ZREVRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +); + +/** + * ZREVRANGEBYSCORE + * + * Return a range of members in a sorted set, by score, with scores ordered from high to low + * + * Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the + * number of elements being returned. If M is constant (e.g. always asking for + * the first 10 elements with LIMIT), you can consider it O(log(N)). + + * - Valid values for withscores: "WITHSCORES" + * Annotated return value: array + */ +int ZREVRANGEBYSCORE( + string key, + // Redis type: double + float max, + // Redis type: double + float min, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +); + +/** + * ZREVRANK + * + * Determine the index of a member in a sorted set, with scores ordered from high to low + * + * Time complexity: O(log(N)) + * Annotated return value: integer + */ +int ZREVRANK( + string key, + string member +); + +/** + * ZSCORE + * + * Get the score associated with the given member in a sorted set + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int ZSCORE( + string key, + string member +); + +/** + * ZUNIONSTORE + * + * Add multiple sorted sets and store the resulting sorted set in a new key + * + * Time complexity: O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, + * and M being the number of elements in the resulting sorted set. + + * - Valid values for aggregate_aggregate: "SUM", "MIN", "MAX" + * Annotated return value: integer + */ +int ZUNIONSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +); + +/** + * SCAN + * + * Incrementally iterate the keys space + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection. + * Annotated return value: + */ +int SCAN( + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0, + string type_type = "" +); + +/** + * SSCAN + * + * Incrementally iterate Set elements + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int SSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * HSCAN + * + * Incrementally iterate hash fields and associated values + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int HSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * ZSCAN + * + * Incrementally iterate sorted sets elements and associated scores + * + * Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command + * calls for the cursor to return back to 0. N is the number of elements inside + * the collection.. + * Annotated return value: + */ +int ZSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +); + +/** + * XINFO + * + * Get information on streams and consumer groups + * + * Time complexity: O(N) with N being the number of returned items for the subcommands CONSUMERS + * and GROUPS. The STREAM subcommand is O(log N) with N being the number of + * items in the stream. + + * - Valid values for help: "HELP" + * Annotated return value: + */ +int XINFO( + // Redis type: key + string consumers_key = "", + string consumers_groupname = "", + // Redis type: key + string groups_key = "", + // Redis type: key + string stream_key = "", + // Redis type: enum + string help = "" +); + +/** + * XADD + * + * Appends a new entry to a stream + * + * Time complexity: O(1) + * Annotated return value: bulk-string + */ +int XADD( + string key, + string ID, + // Redis type: value + string field, + string str +); + +/** + * XTRIM + * + * Trims the stream to (approximately if '~' is passed) a certain size + * + * Time complexity: O(N), with N being the number of evicted entries. Constant times are very + * small however, since entries are organized in macro nodes containing + * multiple entries that can be released with a single deallocation. + + * - Valid values for strategy: "MAXLEN" + + * - Valid values for approx: "~" + * Annotated return value: integer + */ +int XTRIM( + string key, + // Redis type: enum + string strategy, + // Redis type: enum + string approx = "", + // Redis type: integer + int count = 0 +); + +/** + * XDEL + * + * Removes the specified entries from the stream. Returns the number of items actually deleted, that may be different from the number of IDs passed in case certain IDs do not exist. + * + * Time complexity: O(1) for each single item to delete in the stream, regardless of the stream + * size. + * Annotated return value: integer + */ +int XDEL( + string key, + string ID +); + +/** + * XRANGE + * + * Return a range of elements in a stream, with IDs matching the specified IDs interval + * + * Time complexity: O(N) with N being the number of elements being returned. If N is constant + * (e.g. always asking for the first 10 elements with COUNT), you can consider + * it O(1). + * Annotated return value: array + */ +int XRANGE( + string key, + string start, + string end, + // Redis type: integer + int count_count = 0 +); + +/** + * XREVRANGE + * + * Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE + * + * Time complexity: O(N) with N being the number of elements returned. If N is constant (e.g. + * always asking for the first 10 elements with COUNT), you can consider it + * O(1). + * Annotated return value: array + */ +int XREVRANGE( + string key, + string end, + string start, + // Redis type: integer + int count_count = 0 +); + +/** + * XLEN + * + * Return the number of entires in a stream + * + * Time complexity: O(1) + * Annotated return value: integer + */ +int XLEN( + string key +); + +/** + * XREAD + * + * Return never seen elements in multiple streams, with IDs greater than the ones reported by the caller for each stream. Can block. + * + * Time complexity: For each stream mentioned: O(N) with N being the number of elements being + * returned, it menas that XREAD-ing with a fixed COUNT is O(1). Note that when + * the BLOCK option is used, XADD will pay O(M) time in order to serve the M + * clients blocked on the stream getting new data. + + * - Valid values for streams: "STREAMS" + * Annotated return value: array + */ +int XREAD( + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +); + +/** + * XGROUP + * + * Create, destroy, and manage consumer groups. + * + * Time complexity: O(1) for all the subcommands, with the exception of the DESTROY subcommand + * which takes an additional O(M) time in order to delete the M entries inside + * the consumer group pending entries list (PEL). + * Annotated return value: + */ +int XGROUP( + // Redis type: key + string create_key = "", + string create_groupname = "", + string create_id_or__ = "", + // Redis type: key + string setid_key = "", + string setid_groupname = "", + string setid_id_or__ = "", + // Redis type: key + string destroy_key = "", + string destroy_groupname = "", + // Redis type: key + string delconsumer_key = "", + string delconsumer_groupname = "", + string delconsumer_consumername = "" +); + +/** + * XREADGROUP + * + * Return new entries from a stream using a consumer group, or access the history of the pending entries for a given consumer. Can block. + * + * Time complexity: For each stream mentioned: O(M) with M being the number of elements + * returned. If M is constant (e.g. always asking for the first 10 elements + * with COUNT), you can consider it O(1). On the other side when XREADGROUP + * blocks, XADD will pay the O(N) time in order to serve the N clients blocked + * on the stream getting new data. + + * - Valid values for noack: "NOACK" + + * - Valid values for streams: "STREAMS" + * Annotated return value: + */ +int XREADGROUP( + string group_group, + string group_consumer, + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string noack = "", + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +); + +/** + * XACK + * + * Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL. + * + * Time complexity: O(1) for each message ID processed. + * Annotated return value: integer + */ +int XACK( + string key, + string group, + string ID +); + +/** + * XCLAIM + * + * Changes (or acquires) ownership of a message in a consumer group, as if the message was delivered to the specified consumer. + * + * Time complexity: O(log N) with N being the number of messages in the PEL of the consumer + * group. + * Annotated return value: array + */ +int XCLAIM( + string key, + string group, + string consumer, + string min_idle_time, + string ID, + // Redis type: integer + int idle_ms = 0, + // Redis type: integer + int time_ms_unix_time = 0, + // Redis type: integer + int retrycount_count = 0 +); + +/** + * XPENDING + * + * Return information and entries from a stream consumer group pending entries list, that are messages fetched but never acknowledged. + * + * Time complexity: O(N) with N being the number of elements returned, so asking for a small + * fixed number of entries per call is O(1). When the command returns just the + * summary it runs in O(1) time assuming the list of consumers is small, + * otherwise there is additional O(N) time needed to iterate every consumer. + * Annotated return value: array + */ +int XPENDING( + string key, + string group, + string start = "", + string end = "", + // Redis type: integer + int count = 0, + string consumer = "" +); + + + +// Implementation below +int APPEND( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "APPEND"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int AUTH( + string password +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "AUTH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", password); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BGREWRITEAOF() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BGREWRITEAOF"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BGSAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BGSAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BITCOUNT( + string key, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (start != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + if (end != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BITFIELD( + string key, + // Redis type: type + string get_type = "", + // Redis type: integer + int get_offset = 0, + // Redis type: type + string set_type = "", + // Redis type: integer + int set_offset = 0, + // Redis type: integer + int set_value = 0, + // Redis type: type + string incrby_type = "", + // Redis type: integer + int incrby_offset = 0, + // Redis type: integer + int incrby_increment = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITFIELD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (get_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", get_type); + if (get_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(get_offset)); + if (set_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", set_type); + if (set_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(set_offset)); + if (set_value != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(set_value)); + if (incrby_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", incrby_type); + if (incrby_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(incrby_offset)); + if (incrby_increment != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(incrby_increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BITOP( + string operation, + // Redis type: key + string destkey, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", operation); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destkey); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BITPOS( + string key, + // Redis type: integer + int bit, + // Redis type: integer + int start = 0, + // Redis type: integer + int end = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BITPOS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(bit)); + if (start != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + if (end != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BLPOP( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BLPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BRPOP( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BRPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BRPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BRPOPLPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BZPOPMIN( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BZPOPMIN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int BZPOPMAX( + string key, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "BZPOPMAX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_ID() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_ID"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_KILL( + string ip_port = "", + // Redis type: integer + int id_client_id = 0, + string addr_ip_port = "", + string skipme_yes_no = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_KILL"); + if (ip_port != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", ip_port); + if (id_client_id != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(id_client_id)); + if (addr_ip_port != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", addr_ip_port); + if (skipme_yes_no != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", skipme_yes_no); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_LIST() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_LIST"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_GETNAME() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_GETNAME"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_PAUSE( + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_PAUSE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_REPLY( + // Redis type: enum + string reply_mode +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_REPLY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", reply_mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_SETNAME( + string connection_name +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_SETNAME"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", connection_name); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLIENT_UNBLOCK( + string client_id, + // Redis type: enum + string unblock_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLIENT_UNBLOCK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", client_id); + if (unblock_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", unblock_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_ADDSLOTS( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_ADDSLOTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_COUNT_FAILURE_REPORTS( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_COUNT_FAILURE_REPORTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_COUNTKEYSINSLOT( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_COUNTKEYSINSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_DELSLOTS( + // Redis type: integer + int slot +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_DELSLOTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_FAILOVER( + // Redis type: enum + string options = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_FAILOVER"); + if (options != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", options); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_FORGET( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_FORGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_GETKEYSINSLOT( + // Redis type: integer + int slot, + // Redis type: integer + int count +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_GETKEYSINSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_INFO() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_INFO"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_KEYSLOT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_KEYSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_MEET( + string ip, + // Redis type: integer + int port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_MEET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ip); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(port)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_NODES() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_NODES"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_REPLICATE( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_REPLICATE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_RESET( + // Redis type: enum + string reset_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_RESET"); + if (reset_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", reset_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_SAVECONFIG() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SAVECONFIG"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_SET_CONFIG_EPOCH( + // Redis type: integer + int config_epoch +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SET_CONFIG_EPOCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(config_epoch)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_SETSLOT( + // Redis type: integer + int slot, + // Redis type: enum + string subcommand, + string node_id = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SETSLOT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(slot)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (node_id != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_SLAVES( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SLAVES"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_REPLICAS( + string node_id +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_REPLICAS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", node_id); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CLUSTER_SLOTS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CLUSTER_SLOTS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int COMMAND() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int COMMAND_COUNT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_COUNT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int COMMAND_GETKEYS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_GETKEYS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int COMMAND_INFO( + string command_name +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "COMMAND_INFO"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", command_name); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CONFIG_GET( + string parameter +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_GET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", parameter); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CONFIG_REWRITE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_REWRITE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CONFIG_SET( + string parameter, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_SET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", parameter); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int CONFIG_RESETSTAT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "CONFIG_RESETSTAT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DBSIZE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DBSIZE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DEBUG_OBJECT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEBUG_OBJECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DEBUG_SEGFAULT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEBUG_SEGFAULT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DECR( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DECR"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DECRBY( + string key, + // Redis type: integer + int decrement +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DECRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(decrement)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DEL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DISCARD() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DISCARD"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int DUMP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "DUMP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ECHO( + string message +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ECHO"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EVAL( + string script, + // Redis type: integer + int numkeys, + string key, + string arg +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EVAL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", script); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", arg); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EVALSHA( + string sha1, + // Redis type: integer + int numkeys, + string key, + string arg +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EVALSHA"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sha1); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", arg); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EXEC() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXEC"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EXISTS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EXPIRE( + string key, + // Redis type: integer + int seconds +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXPIRE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(seconds)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int EXPIREAT( + string key, + // Redis type: posix time + string timestamp +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "EXPIREAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", timestamp); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int FLUSHALL( + // Redis type: enum + string async = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "FLUSHALL"); + if (async != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", async); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int FLUSHDB( + // Redis type: enum + string async = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "FLUSHDB"); + if (async != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", async); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEOADD( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(longitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(latitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEOHASH( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOHASH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEOPOS( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEOPOS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEODIST( + string key, + string member1, + string member2, + string unit = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEODIST"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member1); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member2); + if (unit != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEORADIUS( + string key, + // Redis type: double + float longitude, + // Redis type: double + float latitude, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEORADIUS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(longitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(latitude, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(radius, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + if (withcoord != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withcoord); + if (withdist != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withdist); + if (withhash != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withhash); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (store_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_key); + if (storedist_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", storedist_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GEORADIUSBYMEMBER( + string key, + string member, + // Redis type: double + float radius, + // Redis type: enum + string unit, + // Redis type: enum + string withcoord = "", + // Redis type: enum + string withdist = "", + // Redis type: enum + string withhash = "", + // Redis type: integer + int count_count = 0, + // Redis type: enum + string order = "", + // Redis type: key + string store_key = "", + // Redis type: key + string storedist_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GEORADIUSBYMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(radius, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", unit); + if (withcoord != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withcoord); + if (withdist != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withdist); + if (withhash != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withhash); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (store_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_key); + if (storedist_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", storedist_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GET( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GETBIT( + string key, + // Redis type: integer + int offset +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETBIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GETRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int end +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(end)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int GETSET( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "GETSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HDEL( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HDEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HEXISTS( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HEXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HGET( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HGETALL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HGETALL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HINCRBY( + string key, + string field, + // Redis type: integer + int increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HINCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HINCRBYFLOAT( + string key, + string field, + // Redis type: double + float increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HINCRBYFLOAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(increment, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HKEYS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HKEYS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HMGET( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HMGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HMSET( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HMSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HSET( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HSETNX( + string key, + string field, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HSTRLEN( + string key, + string field +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSTRLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HVALS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HVALS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int INCR( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCR"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int INCRBY( + string key, + // Redis type: integer + int increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int INCRBYFLOAT( + string key, + // Redis type: double + float increment +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INCRBYFLOAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(increment, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int INFO( + string section = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "INFO"); + if (section != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", section); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int KEYS( + string pattern +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "KEYS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", pattern); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LASTSAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LASTSAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LINDEX( + string key, + // Redis type: integer + int index +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LINDEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LINSERT( + string key, + // Redis type: enum + string where, + string pivot, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LINSERT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", where); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", pivot); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LPOP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LPUSH( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LPUSHX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LPUSHX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LREM( + string key, + // Redis type: integer + int count, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LSET( + string key, + // Redis type: integer + int index, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int LTRIM( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "LTRIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_DOCTOR() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_DOCTOR"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_HELP() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_HELP"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_MALLOC_STATS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_MALLOC_STATS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_PURGE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_PURGE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_STATS() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_STATS"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MEMORY_USAGE( + string key, + // Redis type: integer + int samples_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MEMORY_USAGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (samples_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(samples_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MGET( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MGET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MIGRATE( + string host, + string port, + // Redis type: enum + string key, + // Redis type: integer + int destination_db, + // Redis type: integer + int timeout, + // Redis type: enum + string copy = "", + // Redis type: enum + string replace = "", + string auth_password = "", + // Redis type: key + string keys_key = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MIGRATE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(destination_db)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + if (copy != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", copy); + if (replace != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", replace); + if (auth_password != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", auth_password); + if (keys_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", keys_key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MONITOR() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MONITOR"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MOVE( + string key, + // Redis type: integer + int db +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MOVE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(db)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MSET( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MSET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MSETNX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MSETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int MULTI() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "MULTI"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int OBJECT( + string subcommand, + string arguments = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "OBJECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (arguments != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", arguments); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PERSIST( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PERSIST"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PEXPIRE( + string key, + // Redis type: integer + int milliseconds +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PEXPIRE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(milliseconds)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PEXPIREAT( + string key, + // Redis type: posix time + string milliseconds_timestamp +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PEXPIREAT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", milliseconds_timestamp); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PFADD( + string key, + string element +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", element); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PFCOUNT( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PFMERGE( + // Redis type: key + string destkey, + // Redis type: key + string sourcekey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PFMERGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destkey); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sourcekey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PING( + string message = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PING"); + if (message != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PSETEX( + string key, + // Redis type: integer + int milliseconds, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PSETEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(milliseconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PUBSUB( + string subcommand, + string argument = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PUBSUB"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (argument != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", argument); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PTTL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PTTL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int PUBLISH( + string channel, + string message +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "PUBLISH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", channel); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", message); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int QUIT() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "QUIT"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RANDOMKEY() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RANDOMKEY"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int READONLY() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "READONLY"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int READWRITE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "READWRITE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RENAME( + string key, + // Redis type: key + string newkey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RENAME"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", newkey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RENAMENX( + string key, + // Redis type: key + string newkey +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RENAMENX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", newkey); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RESTORE( + string key, + // Redis type: integer + int ttl, + string serialized_value, + // Redis type: enum + string replace = "", + // Redis type: enum + string absttl = "", + // Redis type: integer + int idletime_seconds = 0, + // Redis type: integer + int freq_frequency = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RESTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(ttl)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", serialized_value); + if (replace != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", replace); + if (absttl != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", absttl); + if (idletime_seconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(idletime_seconds)); + if (freq_frequency != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(freq_frequency)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ROLE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ROLE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RPOP( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RPOPLPUSH( + // Redis type: key + string source, + // Redis type: key + string destination +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPOPLPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RPUSH( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPUSH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int RPUSHX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "RPUSHX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SADD( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SAVE() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SAVE"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCARD( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCARD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCRIPT_DEBUG( + // Redis type: enum + string mode +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_DEBUG"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCRIPT_EXISTS( + string sha1 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_EXISTS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", sha1); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCRIPT_FLUSH() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_FLUSH"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCRIPT_KILL() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_KILL"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCRIPT_LOAD( + string script +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCRIPT_LOAD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", script); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SDIFF( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SDIFF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SDIFFSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SDIFFSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SELECT( + // Redis type: integer + int index +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SELECT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SET( + string key, + string value, + // Redis type: enum + string condition = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SET"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + if (condition != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", condition); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SETBIT( + string key, + // Redis type: integer + int offset, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETBIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SETEX( + string key, + // Redis type: integer + int seconds, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(seconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SETNX( + string key, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETNX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SETRANGE( + string key, + // Redis type: integer + int offset, + string value +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SETRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(offset)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", value); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SHUTDOWN( + // Redis type: enum + string save_mode = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SHUTDOWN"); + if (save_mode != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", save_mode); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SINTER( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SINTER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SINTERSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SINTERSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SISMEMBER( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SISMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SLAVEOF( + string host, + string port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SLAVEOF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int REPLICAOF( + string host, + string port +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "REPLICAOF"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", host); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", port); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SLOWLOG( + string subcommand, + string argument = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SLOWLOG"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", subcommand); + if (argument != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", argument); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SMEMBERS( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SMEMBERS"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SMOVE( + // Redis type: key + string source, + // Redis type: key + string destination, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SMOVE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", source); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SORT( + string key, + // Redis type: pattern + string by_pattern = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0, + string get_pattern = "", + // Redis type: enum + string order = "", + // Redis type: enum + string sorting = "", + // Redis type: key + string store_destination = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SORT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (by_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", by_pattern); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + if (get_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", get_pattern); + if (order != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", order); + if (sorting != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", sorting); + if (store_destination != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", store_destination); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SPOP( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SPOP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SRANDMEMBER( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SRANDMEMBER"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SREM( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int STRLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "STRLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SUNION( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SUNION"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SUNIONSTORE( + // Redis type: key + string destination, + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SUNIONSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SWAPDB( + // Redis type: integer + int index, + // Redis type: integer + int index_1 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SWAPDB"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(index_1)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SYNC() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SYNC"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int TIME() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TIME"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int TOUCH( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TOUCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int TTL( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TTL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int TYPE( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "TYPE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int UNLINK( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "UNLINK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int UNWATCH() { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "UNWATCH"); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int WAIT( + // Redis type: integer + int numreplicas, + // Redis type: integer + int timeout +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "WAIT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numreplicas)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(timeout)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int WATCH( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "WATCH"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZADD( + string key, + // Redis type: enum + string condition = "", + // Redis type: enum + string change = "", + // Redis type: enum + string increment = "", + // Redis type: double + float score = 0.0, + string member = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (condition != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", condition); + if (change != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", change); + if (increment != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", increment); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(score, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZCARD( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZCARD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZCOUNT( + string key, + // Redis type: double + float min, + // Redis type: double + float max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZINCRBY( + string key, + // Redis type: integer + int increment, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZINCRBY"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(increment)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZINTERSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZINTERSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (weights_weight != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(weights_weight)); + if (aggregate_aggregate != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", aggregate_aggregate); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZLEXCOUNT( + string key, + string min, + string max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZLEXCOUNT"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZPOPMAX( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZPOPMAX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZPOPMIN( + string key, + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZPOPMIN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZRANGEBYLEX( + string key, + string min, + string max, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREVRANGEBYLEX( + string key, + string max, + string min, + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZRANK( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREM( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREMRANGEBYLEX( + string key, + string min, + string max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYLEX"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", max); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREMRANGEBYRANK( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREMRANGEBYSCORE( + string key, + // Redis type: double + float min, + // Redis type: double + float max +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREMRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREVRANGE( + string key, + // Redis type: integer + int start, + // Redis type: integer + int stop, + // Redis type: enum + string withscores = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(start)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(stop)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREVRANGEBYSCORE( + string key, + // Redis type: double + float max, + // Redis type: double + float min, + // Redis type: enum + string withscores = "", + // Redis type: integer + int limit_offset = 0, + // Redis type: integer + int limit_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANGEBYSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(max, 0)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", FloatToString(min, 0)); + if (withscores != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", withscores); + if (limit_offset != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_offset)); + if (limit_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(limit_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZREVRANK( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZREVRANK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZSCORE( + string key, + string member +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZSCORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", member); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZUNIONSTORE( + // Redis type: key + string destination, + // Redis type: integer + int numkeys, + string key, + // Redis type: integer + int weights_weight = 0, + // Redis type: enum + string aggregate_aggregate = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZUNIONSTORE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", destination); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(numkeys)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + if (weights_weight != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(weights_weight)); + if (aggregate_aggregate != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", aggregate_aggregate); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SCAN( + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0, + string type_type = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (type_type != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", type_type); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int SSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "SSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int HSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "HSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int ZSCAN( + string key, + // Redis type: integer + int cursor, + // Redis type: pattern + string match_pattern = "", + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "ZSCAN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(cursor)); + if (match_pattern != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", match_pattern); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XINFO( + // Redis type: key + string consumers_key = "", + string consumers_groupname = "", + // Redis type: key + string groups_key = "", + // Redis type: key + string stream_key = "", + // Redis type: enum + string help = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XINFO"); + if (consumers_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumers_key); + if (consumers_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumers_groupname); + if (groups_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", groups_key); + if (stream_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", stream_key); + if (help != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", help); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XADD( + string key, + string ID, + // Redis type: value + string field, + string str +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XADD"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", field); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", str); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XTRIM( + string key, + // Redis type: enum + string strategy, + // Redis type: enum + string approx = "", + // Redis type: integer + int count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XTRIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", strategy); + if (approx != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", approx); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XDEL( + string key, + string ID +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XDEL"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XRANGE( + string key, + string start, + string end, + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XREVRANGE( + string key, + string end, + string start, + // Redis type: integer + int count_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREVRANGE"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XLEN( + string key +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XLEN"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XREAD( + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREAD"); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (block_milliseconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(block_milliseconds)); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", streams); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XGROUP( + // Redis type: key + string create_key = "", + string create_groupname = "", + string create_id_or__ = "", + // Redis type: key + string setid_key = "", + string setid_groupname = "", + string setid_id_or__ = "", + // Redis type: key + string destroy_key = "", + string destroy_groupname = "", + // Redis type: key + string delconsumer_key = "", + string delconsumer_groupname = "", + string delconsumer_consumername = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XGROUP"); + if (create_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_key); + if (create_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_groupname); + if (create_id_or__ != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", create_id_or__); + if (setid_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_key); + if (setid_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_groupname); + if (setid_id_or__ != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", setid_id_or__); + if (destroy_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", destroy_key); + if (destroy_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", destroy_groupname); + if (delconsumer_key != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_key); + if (delconsumer_groupname != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_groupname); + if (delconsumer_consumername != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", delconsumer_consumername); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XREADGROUP( + string group_group, + string group_consumer, + // Redis type: integer + int count_count = 0, + // Redis type: integer + int block_milliseconds = 0, + // Redis type: enum + string noack = "", + // Redis type: enum + string streams = "", + string key = "", + string ID = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XREADGROUP"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group_group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group_consumer); + if (count_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count_count)); + if (block_milliseconds != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(block_milliseconds)); + if (noack != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", noack); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", streams); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XACK( + string key, + string group, + string ID +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XACK"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XCLAIM( + string key, + string group, + string consumer, + string min_idle_time, + string ID, + // Redis type: integer + int idle_ms = 0, + // Redis type: integer + int time_ms_unix_time = 0, + // Redis type: integer + int retrycount_count = 0 +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XCLAIM"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumer); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", min_idle_time); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", ID); + if (idle_ms != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(idle_ms)); + if (time_ms_unix_time != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(time_ms_unix_time)); + if (retrycount_count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(retrycount_count)); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + +int XPENDING( + string key, + string group, + string start = "", + string end = "", + // Redis type: integer + int count = 0, + string consumer = "" +) { + NWNX_PushArgumentString("NWNX_Redis", "Deferred", "XPENDING"); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", key); + NWNX_PushArgumentString("NWNX_Redis", "Deferred", group); + if (start != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", start); + if (end != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", end); + if (count != 0) NWNX_PushArgumentString("NWNX_Redis", "Deferred", IntToString(count)); + if (consumer != "") NWNX_PushArgumentString("NWNX_Redis", "Deferred", consumer); + NWNX_CallFunction("NWNX_Redis", "Deferred"); + return NWNX_GetReturnValueInt("NWNX_Redis", "Deferred"); +} + diff --git a/nwnds_module/nwnx_regex.nss b/nwnds_module/nwnx_regex.nss new file mode 100644 index 000000000..7b737f784 --- /dev/null +++ b/nwnds_module/nwnx_regex.nss @@ -0,0 +1,42 @@ +/// @addtogroup regex Regex +/// @brief Provide regular expression functions. +/// @{ +/// @file nwnx_regex.nss +#include "nwnx" + +const string NWNX_Regex = "NWNX_Regex"; ///< @private + +/// @param str The string to search. +/// @param regex The regular expression to use when searching. +/// @return TRUE if string matches the regular expression. +int NWNX_Regex_Search(string str, string regex); + +/// @brief Replaces any matches of the regular expression with a string. +/// @param str The string to search. +/// @param regex The regular expression to use when searching. +/// @param replace The string to replace the matches with. +/// @param firstOnly Set to TRUE to only replace the first match. +/// @return A new string with any replacements made. +string NWNX_Regex_Replace(string str, string regex, string replace = "", int firstOnly = FALSE); + +/// @} + +int NWNX_Regex_Search(string str, string regex) +{ + string sFunc = "Search"; + NWNX_PushArgumentString(NWNX_Regex, sFunc, regex); + NWNX_PushArgumentString(NWNX_Regex, sFunc, str); + NWNX_CallFunction(NWNX_Regex, sFunc); + return NWNX_GetReturnValueInt(NWNX_Regex, sFunc); +} + +string NWNX_Regex_Replace(string str, string regex, string replace="", int firstOnly=0) +{ + string sFunc = "Replace"; + NWNX_PushArgumentInt(NWNX_Regex, sFunc, firstOnly); + NWNX_PushArgumentString(NWNX_Regex, sFunc, replace); + NWNX_PushArgumentString(NWNX_Regex, sFunc, regex); + NWNX_PushArgumentString(NWNX_Regex, sFunc, str); + NWNX_CallFunction(NWNX_Regex, sFunc); + return NWNX_GetReturnValueString(NWNX_Regex, sFunc); +} diff --git a/nwnds_module/nwnx_rename.nss b/nwnds_module/nwnx_rename.nss new file mode 100644 index 000000000..053fb2a5a --- /dev/null +++ b/nwnds_module/nwnx_rename.nss @@ -0,0 +1,80 @@ +/// @addtogroup rename Rename +/// @brief Facilitates renaming, overriding and customization of player names. +/// @{ +/// @file nwnx_rename.nss +#include "nwnx" + +const string NWNX_Rename = "NWNX_Rename"; ///< @private + +/// @anchor rename_comm_name_override_type +/// @name Community Name Override Type +/// @{ +const int NWNX_RENAME_PLAYERNAME_DEFAULT = 0; ///< Don't rename +const int NWNX_RENAME_PLAYERNAME_OBFUSCATE = 1; ///< Generate random string for Community Name +const int NWNX_RENAME_PLAYERNAME_OVERRIDE = 2; ///< Use character name specified +const int NWNX_RENAME_PLAYERNAME_ANONYMOUS = 3; ///< Use the value of the NWNX_RENAME_ANONYMOUS_NAME environment variable +///@} + +/// @brief Set a PC's character name and community name on the player list. +/// @param oTarget The PC whose name is being overridden. +/// @param sNewName The new name. +/// @param sPrefix The prefix for their character name, sometimes used for a color code. +/// @param sSuffix The suffix for their character name. +/// @param iPlayerNameState How to change the Community Name, use @ref rename_comm_name_override_type "Community Name Override Type". +/// @param oObserver If specified, the character name will appear to that specific observer as set, this overrides a global setting. +/// @note Will not persist through saving, resets or logout. +void NWNX_Rename_SetPCNameOverride(object oTarget, string sNewName, string sPrefix = "" , string sSuffix = "" , + int iPlayerNameState = NWNX_RENAME_PLAYERNAME_DEFAULT, object oObserver = OBJECT_INVALID); + +/// @brief Gets a PC's name as overridden. +/// @param oTarget The PC whose name to query. +/// @param oObserver The specific observer. +/// @return The PC's name as overridden either per observer or globally. +/// @note If you wish to get a PC's true name use `GetName(oPC, TRUE)`. +string NWNX_Rename_GetPCNameOverride(object oTarget, object oObserver = OBJECT_INVALID); + +/// @brief Clears an overridden PC Name. +/// @param oTarget The PC whose overridden name to clear, use OBJECT_INVALID if you're clearing all overrides for an observer. +/// @param oObserver The observer whose overriden name of oTarget is being cleared. +/// If oTarget is OBJECT_INVALID then all overrides are cleared. +/// @param clearAll If true, both the global and personal overrides will be cleared for that target PC. +/// Requires oObserver be OBJECT_INVALID. +void NWNX_Rename_ClearPCNameOverride(object oTarget, object oObserver = OBJECT_INVALID, int clearAll = FALSE); + +/// @} + +void NWNX_Rename_SetPCNameOverride(object oTarget, string sNewName, string sPrefix = "" , string sSuffix = "" , + int iPlayerNameState = NWNX_RENAME_PLAYERNAME_DEFAULT, object oObserver = OBJECT_INVALID) +{ + string sFunc = "SetPCNameOverride"; + + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oObserver); + NWNX_PushArgumentInt(NWNX_Rename, sFunc, iPlayerNameState); + NWNX_PushArgumentString(NWNX_Rename, sFunc, sSuffix); + NWNX_PushArgumentString(NWNX_Rename, sFunc, sPrefix); + NWNX_PushArgumentString(NWNX_Rename, sFunc, sNewName); + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oTarget); + + NWNX_CallFunction(NWNX_Rename, sFunc); +} +string NWNX_Rename_GetPCNameOverride(object oTarget, object oObserver = OBJECT_INVALID) +{ + string sFunc = "GetPCNameOverride"; + + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oObserver); + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oTarget); + + NWNX_CallFunction(NWNX_Rename, sFunc); + return NWNX_GetReturnValueString(NWNX_Rename, sFunc); +} + +void NWNX_Rename_ClearPCNameOverride(object oTarget, object oObserver = OBJECT_INVALID, int clearAll = FALSE) +{ + string sFunc = "ClearPCNameOverride"; + + NWNX_PushArgumentInt(NWNX_Rename, sFunc, clearAll); + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oObserver); + NWNX_PushArgumentObject(NWNX_Rename, sFunc, oTarget); + + NWNX_CallFunction(NWNX_Rename, sFunc); +} diff --git a/nwnds_module/nwnx_reveal.nss b/nwnds_module/nwnx_reveal.nss new file mode 100644 index 000000000..8ddf2f1fb --- /dev/null +++ b/nwnds_module/nwnx_reveal.nss @@ -0,0 +1,49 @@ +/// @addtogroup reveal Reveal +/// @brief Allows the selective revealing of a stealthing character to another character or their party. +/// @{ +/// @file nwnx_reveal.nss +#include "nwnx" + +const string NWNX_Reveal = "NWNX_Reveal"; ///< @private + +/// @name Reveal Detection Methods +/// @{ +const int NWNX_REVEAL_SEEN = 1; ///< Seen +const int NWNX_REVEAL_HEARD = 0; ///< Heard +///@} + +/// @brief Selectively reveals the character to an observer until the next time they stealth out of sight. +/// @param oHiding The creature who is stealthed. +/// @param oObserver The creature to whom the hider is revealed. +/// @param iDetectionMethod Can be specified to determine whether the hidden creature is seen or heard. +void NWNX_Reveal_RevealTo(object oHiding, object oObserver, int iDetectionMethod = NWNX_REVEAL_HEARD); + +/// @brief Sets whether a character remains visible to their party through stealth. +/// @param oHiding The creature who is stealthed. +/// @param bReveal TRUE for visible. +/// @param iDetectionMethod Can be specified to determine whether the hidden creature is seen or heard. +void NWNX_Reveal_SetRevealToParty(object oHiding, int bReveal, int iDetectionMethod = NWNX_REVEAL_HEARD); + +/// @} + +void NWNX_Reveal_RevealTo(object oHiding, object oObserver, int iDetectionMethod = NWNX_REVEAL_HEARD) +{ + string sFunc = "RevealTo"; + + NWNX_PushArgumentInt(NWNX_Reveal, sFunc, iDetectionMethod); + NWNX_PushArgumentObject(NWNX_Reveal, sFunc, oObserver); + NWNX_PushArgumentObject(NWNX_Reveal, sFunc, oHiding); + + NWNX_CallFunction(NWNX_Reveal, sFunc); +} + +void NWNX_Reveal_SetRevealToParty(object oHiding, int bReveal, int iDetectionMethod = NWNX_REVEAL_HEARD) +{ + string sFunc = "SetRevealToParty"; + + NWNX_PushArgumentInt(NWNX_Reveal, sFunc, iDetectionMethod); + NWNX_PushArgumentInt(NWNX_Reveal, sFunc, bReveal); + NWNX_PushArgumentObject(NWNX_Reveal, sFunc, oHiding); + + NWNX_CallFunction(NWNX_Reveal, sFunc); +} diff --git a/nwnds_module/nwnx_ruby.nss b/nwnds_module/nwnx_ruby.nss new file mode 100644 index 000000000..24c8f85d7 --- /dev/null +++ b/nwnds_module/nwnx_ruby.nss @@ -0,0 +1,23 @@ +/// @addtogroup ruby Ruby +/// @brief Allows users to execute arbitrary Ruby from the game. +/// @{ +/// @file nwnx_ruby.nss +#include "nwnx" + +const string NWNX_Ruby = "NWNX_Ruby"; ///< @private + +string NWNX_Ruby_Evaluate (string sCode); + +/// @brief Evaluates some ruby code. +/// @param sCode The code to evaluate. +/// @return The output of the call. +string NWNX_Ruby_Evaluate(string sCode) +{ + string sFunc = "Evaluate"; + + NWNX_PushArgumentString (NWNX_Ruby, sFunc, sCode); + NWNX_CallFunction (NWNX_Ruby, sFunc); + return NWNX_GetReturnValueString (NWNX_Ruby, sFunc); +} + +/// @} diff --git a/nwnds_module/nwnx_skillranks.nss b/nwnds_module/nwnx_skillranks.nss new file mode 100644 index 000000000..cc8848315 --- /dev/null +++ b/nwnds_module/nwnx_skillranks.nss @@ -0,0 +1,283 @@ +/// @addtogroup skillranks SkillRanks +/// @brief Enhances and allows for manipulation of skill rank calculations including the ability to build custom +/// skill related feats as well as modifying stock feats. +/// @{ +/// @file nwnx_skillranks.nss +#include "nwnx" + +const string NWNX_SkillRanks = "NWNX_SkillRanks"; ///< @private + +/// @name SkillRanks Key Abilities +/// @anchor skr_key_abilities +/// +/// The abilities as bits +/// @{ +const int NWNX_SKILLRANKS_KEY_ABILITY_STRENGTH = 1; ///< Strength +const int NWNX_SKILLRANKS_KEY_ABILITY_DEXTERITY = 2; ///< Dexterity +const int NWNX_SKILLRANKS_KEY_ABILITY_CONSTITUTION = 4; ///< Constitution +const int NWNX_SKILLRANKS_KEY_ABILITY_INTELLIGENCE = 8; ///< Intelligence +const int NWNX_SKILLRANKS_KEY_ABILITY_WISDOM = 16; ///< Wisdom +const int NWNX_SKILLRANKS_KEY_ABILITY_CHARISMA = 32; ///< Charisma +///@} + +/// @name SkillRanks Key Ability Calculation Method +/// @anchor skr_key_ability_calc_bits +/// +/// Constants used to calculate the ability modifier for a skill. +/// @{ +/// @warning Use only one of these calculations in your mask! If you use more than one the first will be used. +const int NWNX_SKILLRANKS_KEY_ABILITY_CALC_MIN = 64; ///< Use the minimum value of the provided ability scores. +const int NWNX_SKILLRANKS_KEY_ABILITY_CALC_MAX = 128; ///< Use the maximum value of the provided ability scores. +const int NWNX_SKILLRANKS_KEY_ABILITY_CALC_AVERAGE = 256; ///< Use the average value of the provided ability scores. +const int NWNX_SKILLRANKS_KEY_ABILITY_CALC_SUM = 512; ///< Use the sum of the provided ability scores. +///@} + +/// @brief A feat that manipulates skill ranks. +struct NWNX_SkillRanks_SkillFeat +{ + int iSkill; ///< The skill this feat impacts + int iFeat; ///< The feat + + /// Skill feat bonus/penalty + int iModifier; + + /// 1 for Focus, 2 for Epic Focus. This can be set on a feat so NWNX_SkillRanks_SetFocusMod + /// can mass change the modifier for the Skill Focus and Epic Skill Focus feats. + int iFocusFeat; + + /// @brief 255 char bitset string for skill ranks impacted by class levels (like Bardic Knowledge). + /// + /// The right most bit is barbarian (class 0), second from right is bard (class 1) etc. + /// It's not necessary to pass in the entire string, for example Ranger is class 7 and Fighter is 4 + /// If you wanted those class levels to impact the skill modifier you could set sClasses equal to + /// "10010000". From right to left = Barbarian, Bard, Cleric, Druid, Fighter, Monk, Paladin, Ranger + /// You can alternatively use NWNX_SkillRanks_AddSkillFeatClass() for each class + /// @remark If unset but #fClassLevelMod is set, then all classes will be included. + string sClasses; + + /// Levels in class multiplier gives you skill modifier, for example 0.5f would mean 1 point for + /// every two class levels. If #sClasses is not set and this is set then all class levels will be modified. + float fClassLevelMod; + + /// Used for feats like Stonecunning or Trackless Step which restrict skill modifiers by area types. + int iAreaFlagsRequired; + + /// Used for feats like Stonecunning or Trackless Step which restrict skill modifiers by area types. + int iAreaFlagsForbidden; + + /// 1 for Day, 2 for Night - if skill modifiers only take effect based on the day/night cycle or an area + /// that's set to always night. 0 is all hours. + int iDayOrNight; + + /// This allows for feats that bypass the armor check penalty on skill rank calculations. + int bBypassArmorCheckPenalty; + + /// @brief Bitmask of @ref skr_key_abilities "abilities" and @ref skr_key_ability_calc_bits "method to calculate" + /// the ability modifier for a skill. + /// + /// Example **Doctor** Feat that used INT instead of WIS (if higher) for Heal skill would set to: + /// #NWNX_SKILLRANKS_KEY_ABILITY_INTELLIGENCE | #NWNX_SKILLRANKS_KEY_ABILITY_WISDOM | #NWNX_SKILLRANKS_KEY_ABILITY_CALC_MAX; + int iKeyAbilityMask; +}; + +/// @param iSkill The skill to check the feat count. +/// @return The count of feats for a specific skill. +int NWNX_SkillRanks_GetSkillFeatCountForSkill(int iSkill); + +/// @brief Returns a skill feat. +/// @param iSkill The skill. +/// @param iFeat The feat. +/// @return A constructed NWNX_SkillRanks_SkillFeat. +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_GetSkillFeat(int iSkill, int iFeat); + +/// @brief Returns a skill feat by index. +/// @remark Generally used in a loop with NWNX_SkillRanks_GetSkillFeatCountForSkill(). +/// @param iSkill The skill. +/// @param iIndex The index in the list of feats for the skill. +/// @return A constructed NWNX_SkillRanks_SkillFeat. +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_GetSkillFeatForSkillByIndex(int iSkill, int iIndex); + +/// @brief Modifies or creates a skill feat. +/// @param skillFeat The defined NWNX_SkillRanks_SkillFeat. +/// @param createIfNonExistent TRUE to create if the feat does not exist. +void NWNX_SkillRanks_SetSkillFeat(struct NWNX_SkillRanks_SkillFeat skillFeat, int createIfNonExistent = FALSE); + +/// @brief Add classes to a skill feat instead of working with the NWNX_SkillRanks_SkillFeat::sClasses string. +/// +/// Manipulating the sClasses string in the NWNX_SkillRanks_SkillFeat struct can be difficult. This +/// function allows the builder to enter one class at a time. +/// @param skillFeat The NWNX_SkillRanks_SkillFeat for which the sClasses field will be modifier. +/// @param iClass The class to add to the Skill Feat. +/// @return The updated NWNX_SkillRanks_SkillFeat. +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_AddSkillFeatClass(struct NWNX_SkillRanks_SkillFeat skillFeat, int iClass); + +/// @brief Change the modifier value for Skill Focus and Epic Skill Focus feats. +/// +/// The stock modifier on Skill Focus and Epic Skill Focus are 3 and 10 respectively, these can be +/// changed with this function. +/// @param iModifier The new value for the feat modifier. +/// @param iEpic Set to TRUE to change the value for Epic Skill Focus. +void NWNX_SkillRanks_SetSkillFeatFocusModifier(int iModifier, int iEpic = FALSE); + +/// @brief Gets the current penalty to Dexterity based skills when blind. +/// @return The penalty to Dexterity when blind. +int NWNX_SkillRanks_GetBlindnessPenalty(); + +/// @brief Set the value the Dexterity based skills get decreased due to blindness. +/// @remark Default is 4. +/// @param iModifier The penalty to Dexterity when blind. +void NWNX_SkillRanks_SetBlindnessPenalty(int iModifier); + +/// @brief Get a skill modifier for an area. +/// @param oArea The area. +/// @param iSkill The skill to check. +/// @return The modifier to that skill in the area. +int NWNX_SkillRanks_GetAreaModifier(object oArea, int iSkill); + +/// @brief Sets a skill modifier for the area. +/// @param oArea The area. +/// @param iSkill The skill to change. +/// @param iModifier The modifier to the skill in the area. +void NWNX_SkillRanks_SetAreaModifier(object oArea, int iSkill, int iModifier); + +/// @} + +int NWNX_SkillRanks_GetSkillFeatCountForSkill(int iSkill) +{ + string sFunc = "GetSkillFeatCountForSkill"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iSkill); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); + + return NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); +} + +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_GetSkillFeatForSkillByIndex(int iSkill, int iIndex) +{ + string sFunc = "GetSkillFeatForSkillByIndex"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iIndex); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iSkill); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); + + struct NWNX_SkillRanks_SkillFeat skillFeat; + + skillFeat.iSkill = iSkill; + skillFeat.iFeat = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iModifier = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iFocusFeat = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.sClasses = NWNX_GetReturnValueString(NWNX_SkillRanks, sFunc); + skillFeat.fClassLevelMod = NWNX_GetReturnValueFloat(NWNX_SkillRanks, sFunc); + skillFeat.iAreaFlagsRequired = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iAreaFlagsForbidden = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iDayOrNight = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.bBypassArmorCheckPenalty = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iKeyAbilityMask = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + + return skillFeat; +} + +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_GetSkillFeat(int iSkill, int iFeat) +{ + string sFunc = "GetSkillFeat"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iFeat); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iSkill); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); + + struct NWNX_SkillRanks_SkillFeat skillFeat; + + skillFeat.iSkill = iSkill; + skillFeat.iFeat = iFeat; + skillFeat.iModifier = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iFocusFeat = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.sClasses = NWNX_GetReturnValueString(NWNX_SkillRanks, sFunc); + skillFeat.fClassLevelMod = NWNX_GetReturnValueFloat(NWNX_SkillRanks, sFunc); + skillFeat.iAreaFlagsRequired = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iAreaFlagsForbidden = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iDayOrNight = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.bBypassArmorCheckPenalty = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + skillFeat.iKeyAbilityMask = NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); + + return skillFeat; +} + +void NWNX_SkillRanks_SetSkillFeat(struct NWNX_SkillRanks_SkillFeat skillFeat, int createIfNonExistent = FALSE) +{ + string sFunc = "SetSkillFeat"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, createIfNonExistent); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iKeyAbilityMask); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.bBypassArmorCheckPenalty); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iDayOrNight); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iAreaFlagsForbidden); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iAreaFlagsRequired); + NWNX_PushArgumentFloat(NWNX_SkillRanks, sFunc, skillFeat.fClassLevelMod); + // We only need to send the string from the point of the first set bit + NWNX_PushArgumentString(NWNX_SkillRanks, sFunc, GetStringRight(skillFeat.sClasses, GetStringLength(skillFeat.sClasses)-FindSubString(skillFeat.sClasses, "1"))); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iFocusFeat); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iModifier); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iFeat); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, skillFeat.iSkill); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); +} + +struct NWNX_SkillRanks_SkillFeat NWNX_SkillRanks_AddSkillFeatClass(struct NWNX_SkillRanks_SkillFeat skillFeat, int iClass) +{ + if (GetStringLength(skillFeat.sClasses) < 255) + { + int i; + string sPad; + for (i = 0; i < 255-GetStringLength(skillFeat.sClasses); i++) { sPad = sPad + "0"; } + skillFeat.sClasses = sPad + skillFeat.sClasses; + } + skillFeat.sClasses = GetStringLeft(skillFeat.sClasses, 254 - iClass) + "1" + GetStringRight(skillFeat.sClasses, iClass); + return skillFeat; +} + +void NWNX_SkillRanks_SetSkillFeatFocusModifier(int iModifier, int epicFocus = FALSE) +{ + string sFunc = "SetSkillFeatFocusModifier"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, epicFocus); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iModifier); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); +} + +int NWNX_SkillRanks_GetBlindnessPenalty() +{ + string sFunc = "GetBlindnessPenalty"; + + NWNX_CallFunction(NWNX_SkillRanks, sFunc); + + return NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); +} + +void NWNX_SkillRanks_SetBlindnessPenalty(int iModifier) +{ + string sFunc = "SetBlindnessPenalty"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iModifier); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); +} + +int NWNX_SkillRanks_GetAreaModifier(object oArea, int iSkill) +{ + string sFunc = "GetAreaModifier"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iSkill); + NWNX_PushArgumentObject(NWNX_SkillRanks, sFunc, oArea); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); + + return NWNX_GetReturnValueInt(NWNX_SkillRanks, sFunc); +} + +void NWNX_SkillRanks_SetAreaModifier(object oArea, int iSkill, int iModifier) +{ + string sFunc = "SetAreaModifier"; + + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iModifier); + NWNX_PushArgumentInt(NWNX_SkillRanks, sFunc, iSkill); + NWNX_PushArgumentObject(NWNX_SkillRanks, sFunc, oArea); + NWNX_CallFunction(NWNX_SkillRanks, sFunc); +} diff --git a/nwnds_module/nwnx_spellcheck.nss b/nwnds_module/nwnx_spellcheck.nss new file mode 100644 index 000000000..5c75bee02 --- /dev/null +++ b/nwnds_module/nwnx_spellcheck.nss @@ -0,0 +1,43 @@ +/// @addtogroup spellchecker SpellChecker +/// @brief Functions related to spellchecking +/// @{ +/// @file nwnx_spellcheck.nss +#include "nwnx" + +const string NWNX_SpellChecker = "NWNX_SpellChecker"; ///< @private + +/// @brief Finds misspells in a string. +/// @param sentence The sentence to check. +/// @return The spelling mistakes in the sentence, comma delimited. Returns blank if no errors or if .so file +/// is improperly installed. +/// @note If it returns an error in every word, even when spelled correctly, the dictionary is not set up correctly. +/// @warning These functions can be performance heavy, do limit how many calls and/or how long of a sentence is passed. +/// Make use of **DelayCommands** and **AssignCommands** +string NWNX_SpellChecker_FindMisspell(string sentence); + +/// @brief Get suggestions on a single word, comma delimited. +/// @param word The string to check for suggestions. +/// @return A comma delimited lists of suggestions for a word. Returns blank if no errors or if .so file is improperly +/// installed. +/// @warning These functions can be performance heavy, do limit how many calls and/or how long of a sentence is passed. +/// Make use of **DelayCommands** and **AssignCommands** +string NWNX_SpellChecker_GetSuggestSpell(string word); + +/// @} + +string NWNX_SpellChecker_FindMisspell(string sentence) +{ + string sFunc = "FindMisspell"; + + NWNX_PushArgumentString(NWNX_SpellChecker, sFunc, sentence); + NWNX_CallFunction(NWNX_SpellChecker, sFunc); + return NWNX_GetReturnValueString(NWNX_SpellChecker, sFunc); +} + +string NWNX_SpellChecker_GetSuggestSpell(string word) +{ + string sFunc = "GetSuggestSpell"; + NWNX_PushArgumentString(NWNX_SpellChecker, sFunc, word); + NWNX_CallFunction(NWNX_SpellChecker, sFunc); + return NWNX_GetReturnValueString(NWNX_SpellChecker, sFunc); +} diff --git a/nwnds_module/nwnx_sql.nss b/nwnds_module/nwnx_sql.nss new file mode 100644 index 000000000..fdd583fba --- /dev/null +++ b/nwnds_module/nwnx_sql.nss @@ -0,0 +1,254 @@ +/// @addtogroup sql SQL +/// @brief Functions to interface with a database through SQL +/// @{ +/// @file nwnx_sql.nss +#include "nwnx" + +const string NWNX_SQL = "NWNX_SQL"; ///< @private + +/// @brief Prepares the provided query for execution. +/// @note This does not execute the query. Will also clear any previous state. +/// @param query The query to prepare. +/// @return TRUE if the query was successfully prepared. +int NWNX_SQL_PrepareQuery(string query); + +/// @brief Executes a query which has been prepared. +/// @return The ID of this query if successful, else FALSE. +int NWNX_SQL_ExecutePreparedQuery(); + +/// @brief Directly execute an SQL query. +/// @note Clears previously prepared query states. +/// @return The ID of this query if successful, else FALSE. +int NWNX_SQL_ExecuteQuery(string query); + +/// @anchor sql_rtrnr +/// @return TRUE if one or more rows are ready, FALSE otherwise. +int NWNX_SQL_ReadyToReadNextRow(); + +/// @anchor sql_rnr +/// @brief Reads the next row of returned data. +/// @remark Should only be called after a successful call to @ref sql_rtrnr "NWNX_SQL_ReadyToReadNextRow()". +void NWNX_SQL_ReadNextRow(); + +/// @param column The column to read in the active row. +/// @return Data at the nth (0-based) column of the active row. +/// @remark Should only be called after a successful call to @ref sql_rnr "NWNX_SQL_ReadNextRow()". +string NWNX_SQL_ReadDataInActiveRow(int column = 0); + +/// @brief Set the int value of a prepared statement at given position. +/// @param position The nth ? in a prepared statement. +/// @param value The value to set. +void NWNX_SQL_PreparedInt(int position, int value); + +/// @brief Set the string value of a prepared statement at given position. +/// @param position The nth ? in a prepared statement. +/// @param value The value to set. +void NWNX_SQL_PreparedString(int position, string value); + +/// @brief Set the float value of a prepared statement at given position. +/// @param position The nth ? in a prepared statement. +/// @param value The value to set. +void NWNX_SQL_PreparedFloat(int position, float value); + +/// @brief Set the ObjectId value of a prepared statement at given position. +/// @param position The nth ? in a prepared statement. +/// @param value The value to set. +void NWNX_SQL_PreparedObjectId(int position, object value); + +/// @brief Set the full serialized object value of a prepared statement at given position. +/// @param position The nth ? in a prepared statement. +/// @param value The value to set. +/// @param base64 Use base64-encoded string format if TRUE (default), otherwise use binary format. +void NWNX_SQL_PreparedObjectFull(int position, object value, int base64 = TRUE); + +/// @brief Like NWNX_SQL_ReadDataInActiveRow, but for full serialized objects. +/// +/// The object will be deserialized and created in the game. New object ID is returned. +/// +/// The exact behavior depends on type of deserialized object and owner object: +/// * If object is an item, and owner if placeable, creature or container, the item will be created in its inventory +/// * If owner is an area, the object will be created on the ground at Vector(x,y,z) +/// * Otherwise, the object will be created outside the world and needs to be ported manually. +/// +/// @param column The column to read in the active row. +/// @param owner The owner of the object. +/// @param x, y, z The vector for objects to be placed in areas. +/// @param base64 Use base64-encoded string format if TRUE (default), otherwise use binary format. +/// @return The deserialized object. +object NWNX_SQL_ReadFullObjectInActiveRow(int column = 0, object owner = OBJECT_INVALID, float x = 0.0, float y = 0.0, float z = 0.0, int base64 = TRUE); + +/// @brief Gets the rows affected by a query. +/// @remark This command is for non-row-based statements like INSERT, UPDATE, DELETE, etc. +/// @return Number of rows affected by SQL statement or -1 if the query was not non-row-based. +int NWNX_SQL_GetAffectedRows(); + +/// Gets the database type. +/// @return The database type we're interacting with. +/// @remark This is the same value as the value of NWNX_SQL_TYPE environment variable. +string NWNX_SQL_GetDatabaseType(); + +/// @brief Free any resources attached to an existing prepared query. +/// @remark Resources are automatically freed when a new query is prepared, so calling this isn't necessary. +void NWNX_SQL_DestroyPreparedQuery(); + +/// @return The last error message generated by the database. +string NWNX_SQL_GetLastError(); + +/// @brief Gets the number of parameteres expected by a prepared query. +/// @return Returns the number of parameters expected by the prepared query or -1 if no query is prepared. +int NWNX_SQL_GetPreparedQueryParamCount(); + +/// @} + +int NWNX_SQL_PrepareQuery(string query) +{ + string sFunc = "PrepareQuery"; + + NWNX_PushArgumentString(NWNX_SQL, sFunc, query); + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueInt(NWNX_SQL, sFunc); +} + +int NWNX_SQL_ExecutePreparedQuery() +{ + string sFunc = "ExecutePreparedQuery"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueInt(NWNX_SQL, sFunc); +} + +int NWNX_SQL_ExecuteQuery(string query) +{ + // Note: the implementation might change as support for more SQL targets arrives. + if (NWNX_SQL_PrepareQuery(query)) + { + int ret = NWNX_SQL_ExecutePreparedQuery(); + NWNX_SQL_DestroyPreparedQuery(); + return ret; + } + + return FALSE; +} + +int NWNX_SQL_ReadyToReadNextRow() +{ + string sFunc = "ReadyToReadNextRow"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueInt(NWNX_SQL, sFunc); +} + +void NWNX_SQL_ReadNextRow() +{ + string sFunc = "ReadNextRow"; + + NWNX_CallFunction(NWNX_SQL, sFunc); +} + +string NWNX_SQL_ReadDataInActiveRow(int column = 0) +{ + string sFunc = "ReadDataInActiveRow"; + + NWNX_PushArgumentInt(NWNX_SQL, sFunc, column); + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueString(NWNX_SQL, sFunc); +} + + +void NWNX_SQL_PreparedInt(int position, int value) +{ + string sFunc = "PreparedInt"; + + NWNX_PushArgumentInt(NWNX_SQL, sFunc, value); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, position); + NWNX_CallFunction(NWNX_SQL, sFunc); +} +void NWNX_SQL_PreparedString(int position, string value) +{ + string sFunc = "PreparedString"; + + NWNX_PushArgumentString(NWNX_SQL, sFunc, value); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, position); + NWNX_CallFunction(NWNX_SQL, sFunc); + +} +void NWNX_SQL_PreparedFloat(int position, float value) +{ + string sFunc = "PreparedFloat"; + + NWNX_PushArgumentFloat(NWNX_SQL, sFunc, value); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, position); + NWNX_CallFunction(NWNX_SQL, sFunc); + +} +void NWNX_SQL_PreparedObjectId(int position, object value) +{ + string sFunc = "PreparedObjectId"; + + NWNX_PushArgumentObject(NWNX_SQL, sFunc, value); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, position); + NWNX_CallFunction(NWNX_SQL, sFunc); + +} +void NWNX_SQL_PreparedObjectFull(int position, object value, int base64 = TRUE) +{ + string sFunc = "PreparedObjectFull"; + + NWNX_PushArgumentInt(NWNX_SQL, sFunc, base64); + NWNX_PushArgumentObject(NWNX_SQL, sFunc, value); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, position); + NWNX_CallFunction(NWNX_SQL, sFunc); +} + +object NWNX_SQL_ReadFullObjectInActiveRow(int column = 0, object owner = OBJECT_INVALID, float x = 0.0, float y = 0.0, float z = 0.0, int base64 = TRUE) +{ + string sFunc = "ReadFullObjectInActiveRow"; + + NWNX_PushArgumentInt(NWNX_SQL, sFunc, base64); + NWNX_PushArgumentFloat(NWNX_SQL, sFunc, z); + NWNX_PushArgumentFloat(NWNX_SQL, sFunc, y); + NWNX_PushArgumentFloat(NWNX_SQL, sFunc, x); + NWNX_PushArgumentObject(NWNX_SQL, sFunc, owner); + NWNX_PushArgumentInt(NWNX_SQL, sFunc, column); + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueObject(NWNX_SQL, sFunc); +} + +int NWNX_SQL_GetAffectedRows() +{ + string sFunc = "GetAffectedRows"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueInt(NWNX_SQL, sFunc); +} + +string NWNX_SQL_GetDatabaseType() +{ + string sFunc = "GetDatabaseType"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueString(NWNX_SQL, sFunc); +} + +void NWNX_SQL_DestroyPreparedQuery() +{ + string sFunc = "DestroyPreparedQuery"; + + NWNX_CallFunction(NWNX_SQL, sFunc); +} + +string NWNX_SQL_GetLastError() +{ + string sFunc = "GetLastError"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueString(NWNX_SQL, sFunc); +} + +int NWNX_SQL_GetPreparedQueryParamCount() +{ + string sFunc = "GetPreparedQueryParamCount"; + + NWNX_CallFunction(NWNX_SQL, sFunc); + return NWNX_GetReturnValueInt(NWNX_SQL, sFunc); +} diff --git a/nwnds_module/nwnx_tests.nss b/nwnds_module/nwnx_tests.nss new file mode 100644 index 000000000..81b76433e --- /dev/null +++ b/nwnds_module/nwnx_tests.nss @@ -0,0 +1,21 @@ +/// @ingroup nwnx +/// @addtogroup tests NWNX Tests +/// @brief Helper functions when running the test scripts +/// @{ +/// @file nwnx_tests.nss + +/// @brief Reports the test results +/// @param sPlugin The plugin calling the test. +/// @param sTestName The name of the test. +/// @param bSuccess TRUE if the test passed. +void NWNX_Tests_Report(string sPlugin, string sTestName, int bSuccess); + +void NWNX_Tests_Report(string sPlugin, string sTestName, int bSuccess) +{ + if (bSuccess) + WriteTimestampedLogEntry(sPlugin + ": " + sTestName + "() success"); + else + WriteTimestampedLogEntry(sPlugin + ": " + sTestName + "() failed"); +} + +/// @} // End of tests diff --git a/nwnds_module/nwnx_tileset.nss b/nwnds_module/nwnx_tileset.nss new file mode 100644 index 000000000..3b9f71db7 --- /dev/null +++ b/nwnds_module/nwnx_tileset.nss @@ -0,0 +1,371 @@ +/// @addtogroup tileset Tileset +/// @brief An advanced plugin that exposes additional tileset and tile properties and allows builders to override the tiles of an area created with CreateArea(). +/// @{ +/// @file nwnx_tileset.nss +#include "nwnx" + +const string NWNX_Tileset = "NWNX_Tileset"; ///< @private + +/// @brief A structure containing general tileset data. +struct NWNX_Tileset_TilesetData +{ + int nNumTileData; ///< The number of tiles in the tileset. + float fHeightTransition; ///< The height difference between tiles on different heights. + int nNumTerrain; ///< The number of terrains in the tileset. + int nNumCrossers; ///< The number of crossers in the tileset. + int nNumGroups; ///< The number of groups in the tileset. + string sBorderTerrain; ///< The default border terrain of the tileset. + string sDefaultTerrain; ///< The default terrain of the tileset. + string sFloorTerrain; ///< The default floor terrain of the tileset. + int nDisplayNameStrRef; ///< The name of the tileset as strref, -1 if not set. + string sUnlocalizedName; ///< The unlocalized name of the tileset, "" if not set. + int bInterior; ///< The type of tileset. TRUE for interior, FALSE for exterior. + int bHasHeightTransition; ///< TRUE if the tileset supports multiple height levels. FALSE if not. +}; + +/// @brief A structure containing the group data for a tileset. +struct NWNX_Tileset_TilesetGroupData +{ + string sName; ///< The name of the group. + int nStrRef; ///< The StrRef of the group. + int nRows; ///< The number of rows the group has. + int nColumns; ///< The number of columns the group has. +}; + +/// @brief A structure containing the edge and corner types of a tile. +struct NWNX_Tileset_TileEdgesAndCorners +{ + string sTopLeft; ///< The top left corner. + string sTop; ///< The top edge. + string sTopRight; ///< The top right corner. + string sRight; ///< The right edge. + string sBottomRight; ///< The bottom right corner. + string sBottom; ///< The bottom edge. + string sBottomLeft; ///< The bottom left corner. + string sLeft; ///< The left edge. +}; + +/// @brief A structure containing the door data for a tile. +struct NWNX_Tileset_TileDoorData +{ + int nType; ///< The type of door, returns an index into doortypes.2da. + float fX; ///< The X position of the door. + float fY; ///< The Y position of the door. + float fZ; ///< The Z position of the door. + float fOrientation; ///< The orientation of the door. +}; + +/// @brief A structure containing custom tile data, +struct NWNX_Tileset_CustomTileData +{ + int nTileID; ///< The tile ID. See the tileset's .set file. + int nOrientation; ///< The orientation of the tile. Valid values: 0-3. + int nHeight; ///< The height of the tile. + + int nMainLightColor1; ///< A `TILE_MAIN_LIGHT_COLOR_*` value. + int nMainLightColor2; ///< A `TILE_MAIN_LIGHT_COLOR_*` value. + int nSourceLightColor1; ///< A `TILE_SOURCE_LIGHT_COLOR_*` value. + int nSourceLightColor2; ///< A `TILE_SOURCE_LIGHT_COLOR_*` value. + + int bAnimLoop1; ///< A bool to enable or disable the tile's first anim loop. + int bAnimLoop2; ///< A bool to enable or disable the tile's second anim loop. + int bAnimLoop3; ///< A bool to enable or disable the tile's third anim loop. +}; + +/// @brief Get general data of sTileset. +/// @param sTileset The tileset. +/// @return A NWNX_Tileset_TilesetData struct. +struct NWNX_Tileset_TilesetData NWNX_Tileset_GetTilesetData(string sTileset); + +/// @brief Get the name of sTileset's terrain at nIndex. +/// @param sTileset The tileset. +/// @param nIndex The index of the terrain. Range: NWNX_Tileset_TilesetData.nNumTerrain > nIndex >= 0 +/// @return The terrain name or "" on error. +string NWNX_Tileset_GetTilesetTerrain(string sTileset, int nIndex); + +/// @brief Get the name of sTileset's crosser at nIndex. +/// @param sTileset The tileset. +/// @param nIndex The index of the crosser. Range: NWNX_Tileset_TilesetData.nNumCrossers > nIndex >= 0 +/// @return The crosser name or "" on error. +string NWNX_Tileset_GetTilesetCrosser(string sTileset, int nIndex); + +/// @brief Get general data of the group at nIndex in sTileset. +/// @param sTileset The tileset. +/// @param nIndex The index of the group. Range: NWNX_Tileset_TilesetData.nNumGroups > nIndex >= 0 +/// @return A NWNX_Tileset_TilesetGroupData struct. +struct NWNX_Tileset_TilesetGroupData NWNX_Tileset_GetTilesetGroupData(string sTileset, int nIndex); + +/// @brief Get tile ID of the tile at nIndex. +/// @note NWNX_Tileset_GetTilesetGroupData() needs to be called first. +/// @param nIndex The index of the tile. Range: (NWNX_Tileset_TilesetGroupData.nRows * NWNX_Tileset_TilesetGroupData.nColumns) > nIndex >= 0 +/// @return The tile ID or 0 on error. +int NWNX_Tileset_GetTilesetGroupTile(int nIndex); + +/// @brief Get the model name of a tile in sTileset. +/// @param sTileset The tileset. +/// @param nTileID The tile ID. +/// @return The model name or "" on error. +string NWNX_Tileset_GetTileModel(string sTileset, int nTileID); + +/// @brief Get the minimap texture name of a tile in sTileset. +/// @param sTileset The tileset. +/// @param nTileID The tile ID. +/// @return The minimap texture name or "" on error. +string NWNX_Tileset_GetTileMinimapTexture(string sTileset, int nTileID); + +/// @brief Get the edges and corners of a tile in sTileset. +/// @param sTileset The tileset. +/// @param nTileID The tile ID. +/// @return A NWNX_Tileset_TileEdgesAndCorners struct. +struct NWNX_Tileset_TileEdgesAndCorners NWNX_Tileset_GetTileEdgesAndCorners(string sTileset, int nTileID); + +/// @brief Get the number of doors of a tile in sTileset. +/// @param sTileset The tileset. +/// @param nTileID The tile ID. +/// @return The amount of doors. +int NWNX_Tileset_GetTileNumDoors(string sTileset, int nTileID); + +/// @brief Get the door data of a tile in sTileset. +/// @param sTileset The tileset. +/// @param nTileID The tile ID. +/// @param nIndex The index of the door. Range: NWNX_Tileset_GetTileNumDoors() > nIndex >= 0 +/// @return A NWNX_Tileset_TileDoorData struct. +struct NWNX_Tileset_TileDoorData NWNX_Tileset_GetTileDoorData(string sTileset, int nTileID, int nIndex = 0); + +/// @brief Override the tiles of sAreaResRef with data in sOverrideName. +/// @param sAreaResRef The resref of the area to override. +/// @param sOverrideName The name of the override containing the custom tile data or "" to remove the override. +void NWNX_Tileset_SetAreaTileOverride(string sAreaResRef, string sOverrideName); + +/// @brief Create a tile override named sOverrideName. +/// @param sOverrideName The name of the override. +/// @param sTileSet The tileset the override should use. +/// @param nWidth The width of the area. Valid values: 1-32. +/// @param nHeight The height of the area. Valid values: 1-32. +void NWNX_Tileset_CreateTileOverride(string sOverrideName, string sTileSet, int nWidth, int nHeight); + +/// @brief Delete a tile override named sOverrideName. +/// @note This will also delete all custom tile data associated with sOverrideName. +/// @param sOverrideName The name of the override. +void NWNX_Tileset_DeleteTileOverride(string sOverrideName); + +/// @brief Set custom tile data for the tile at nIndex in sOverrideName. +/// @note An override must first be created with NWNX_Tileset_CreateTileOverride(). +/// @param sOverrideName The name of the override. +/// @param nIndex The index of the tile. +/// @param strCustomTileData A NWNX_Tileset_CustomTileData struct. +void NWNX_Tileset_SetOverrideTileData(string sOverrideName, int nIndex, struct NWNX_Tileset_CustomTileData strCustomTileData); + +/// @brief Delete custom tile data of the tile at nIndex in sOverrideName. +/// @param sOverrideName The name of the override. +/// @param nIndex The tile's index or -1 to remove all custom tile data. +void NWNX_Tileset_DeleteOverrideTileData(string sOverrideName, int nIndex); + +/// @} + +struct NWNX_Tileset_TilesetData NWNX_Tileset_GetTilesetData(string sTileset) +{ + string sFunc = "GetTilesetData"; + + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + struct NWNX_Tileset_TilesetData str; + str.bHasHeightTransition = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.bInterior = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.sUnlocalizedName = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.nDisplayNameStrRef = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.sFloorTerrain = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sDefaultTerrain = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sBorderTerrain = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.nNumGroups = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.nNumCrossers = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.nNumTerrain = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.fHeightTransition = NWNX_GetReturnValueFloat(NWNX_Tileset, sFunc); + str.nNumTileData = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + + return str; +} + +string NWNX_Tileset_GetTilesetTerrain(string sTileset, int nIndex) +{ + string sFunc = "GetTilesetTerrain"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueString(NWNX_Tileset, sFunc); +} + +string NWNX_Tileset_GetTilesetCrosser(string sTileset, int nIndex) +{ + string sFunc = "GetTilesetCrosser"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueString(NWNX_Tileset, sFunc); +} + +struct NWNX_Tileset_TilesetGroupData NWNX_Tileset_GetTilesetGroupData(string sTileset, int nIndex) +{ + string sFunc = "GetTilesetGroupData"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + struct NWNX_Tileset_TilesetGroupData str; + str.nColumns = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.nRows = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.nStrRef = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + str.sName = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + + return str; +} + +int NWNX_Tileset_GetTilesetGroupTile(int nIndex) +{ + string sFunc = "GetTilesetGroupTile"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); +} + +string NWNX_Tileset_GetTileModel(string sTileset, int nTileID) +{ + string sFunc = "GetTileModel"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nTileID); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueString(NWNX_Tileset, sFunc); +} + +string NWNX_Tileset_GetTileMinimapTexture(string sTileset, int nTileID) +{ + string sFunc = "GetTileMinimapTexture"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nTileID); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueString(NWNX_Tileset, sFunc); +} + +struct NWNX_Tileset_TileEdgesAndCorners NWNX_Tileset_GetTileEdgesAndCorners(string sTileset, int nTileID) +{ + string sFunc = "GetTileEdgesAndCorners"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nTileID); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + struct NWNX_Tileset_TileEdgesAndCorners str; + str.sLeft = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sBottomLeft = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sBottom = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sBottomRight = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sRight = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sTopRight = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sTop = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + str.sTopLeft = NWNX_GetReturnValueString(NWNX_Tileset, sFunc); + + return str; +} + +int NWNX_Tileset_GetTileNumDoors(string sTileset, int nTileID) +{ + string sFunc = "GetTileNumDoors"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nTileID); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); +} + +struct NWNX_Tileset_TileDoorData NWNX_Tileset_GetTileDoorData(string sTileset, int nTileID, int nIndex = 0) +{ + string sFunc = "GetTileDoorData"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nTileID); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileset); + NWNX_CallFunction(NWNX_Tileset, sFunc); + + struct NWNX_Tileset_TileDoorData str; + str.fOrientation = NWNX_GetReturnValueFloat(NWNX_Tileset, sFunc); + str.fZ = NWNX_GetReturnValueFloat(NWNX_Tileset, sFunc); + str.fY = NWNX_GetReturnValueFloat(NWNX_Tileset, sFunc); + str.fX = NWNX_GetReturnValueFloat(NWNX_Tileset, sFunc); + str.nType = NWNX_GetReturnValueInt(NWNX_Tileset, sFunc); + + return str; +} + +void NWNX_Tileset_SetAreaTileOverride(string sAreaResRef, string sOverrideName) +{ + string sFunc = "SetAreaTileOverride"; + + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sOverrideName); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sAreaResRef); + + NWNX_CallFunction(NWNX_Tileset, sFunc); +} + +void NWNX_Tileset_CreateTileOverride(string sOverrideName, string sTileSet, int nWidth, int nHeight) +{ + string sFunc = "CreateTileOverride"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nHeight); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nWidth); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sTileSet); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sOverrideName); + + NWNX_CallFunction(NWNX_Tileset, sFunc); +} + +void NWNX_Tileset_DeleteTileOverride(string sOverrideName) +{ + string sFunc = "DeleteTileOverride"; + + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sOverrideName); + + NWNX_CallFunction(NWNX_Tileset, sFunc); +} + +void NWNX_Tileset_SetOverrideTileData(string sOverrideName, int nIndex, struct NWNX_Tileset_CustomTileData strCustomTileData) +{ + string sFunc = "SetOverrideTileData"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.bAnimLoop3); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.bAnimLoop2); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.bAnimLoop1); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nSourceLightColor2); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nSourceLightColor1); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nMainLightColor2); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nMainLightColor1); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nHeight); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nOrientation); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, strCustomTileData.nTileID); + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sOverrideName); + + NWNX_CallFunction(NWNX_Tileset, sFunc); +} + +void NWNX_Tileset_DeleteOverrideTileData(string sOverrideName, int nIndex) +{ + string sFunc = "DeleteOverrideTileData"; + + NWNX_PushArgumentInt(NWNX_Tileset, sFunc, nIndex); + NWNX_PushArgumentString(NWNX_Tileset, sFunc, sOverrideName); + + NWNX_CallFunction(NWNX_Tileset, sFunc); +} diff --git a/nwnds_module/nwnx_time.nss b/nwnds_module/nwnx_time.nss new file mode 100644 index 000000000..1e4e71bfc --- /dev/null +++ b/nwnds_module/nwnx_time.nss @@ -0,0 +1,63 @@ +/// @addtogroup time Time +/// @brief Provides various time related functions +/// @{ +/// @file nwnx_time.nss +#include "nwnx" + +const string NWNX_Time = "NWNX_Time"; ///< @private + +/// @brief Returns the current date. +/// @return The date in the format (mm/dd/yyyy). +string NWNX_Time_GetSystemDate(); + +/// @brief Returns current time. +/// @return The current time in the format (24:mm:ss). +string NWNX_Time_GetSystemTime(); + +/// @return Returns the number of seconds since midnight on January 1, 1970. +int NWNX_Time_GetTimeStamp(); + +/// @brief A high resolution timestamp +struct NWNX_Time_HighResTimestamp +{ + int seconds; ///< Seconds since epoch + int microseconds; ///< Microseconds +}; + +/// @return Returns the number of microseconds since midnight on January 1, 1970. +struct NWNX_Time_HighResTimestamp NWNX_Time_GetHighResTimeStamp(); + +/// @} + +string NWNX_Time_GetSystemDate() +{ + string sFunc = "GetSystemDate"; + NWNX_CallFunction(NWNX_Time, sFunc); + return NWNX_GetReturnValueString(NWNX_Time, sFunc); +} + +string NWNX_Time_GetSystemTime() +{ + string sFunc = "GetSystemTime"; + NWNX_CallFunction(NWNX_Time, sFunc); + return NWNX_GetReturnValueString(NWNX_Time, sFunc); +} + +int NWNX_Time_GetTimeStamp() +{ + string sFunc = "GetTimeStamp"; + + NWNX_CallFunction(NWNX_Time, sFunc); + return NWNX_GetReturnValueInt(NWNX_Time, sFunc); +} + +struct NWNX_Time_HighResTimestamp NWNX_Time_GetHighResTimeStamp() +{ + struct NWNX_Time_HighResTimestamp t; + string sFunc = "GetHighResTimeStamp"; + + NWNX_CallFunction(NWNX_Time, sFunc); + t.microseconds = NWNX_GetReturnValueInt(NWNX_Time, sFunc); + t.seconds = NWNX_GetReturnValueInt(NWNX_Time, sFunc); + return t; +} diff --git a/nwnds_module/nwnx_util.nss b/nwnds_module/nwnx_util.nss new file mode 100644 index 000000000..929a5f622 --- /dev/null +++ b/nwnds_module/nwnx_util.nss @@ -0,0 +1,602 @@ +/// @addtogroup util Util +/// @brief Provides various utility functions that don't have a better home +/// @{ +/// @file nwnx_util.nss +#include "nwnx" + +const string NWNX_Util = "NWNX_Util"; ///< @private + +/// @name Resref Types +/// @anchor resref_types +/// Constants for the various types of resrefs. +/// +/// @{ +const int NWNX_UTIL_RESREF_TYPE_NSS = 2009; +const int NWNX_UTIL_RESREF_TYPE_NCS = 2010; +const int NWNX_UTIL_RESREF_TYPE_AREA_ARE = 2012; +const int NWNX_UTIL_RESREF_TYPE_TWODA = 2017; +const int NWNX_UTIL_RESREF_TYPE_AREA_GIT = 2023; +const int NWNX_UTIL_RESREF_TYPE_ITEM = 2025; +const int NWNX_UTIL_RESREF_TYPE_CREATURE = 2027; +const int NWNX_UTIL_RESREF_TYPE_DIALOG = 2029; +const int NWNX_UTIL_RESREF_TYPE_TRIGGER = 2032; +const int NWNX_UTIL_RESREF_TYPE_SOUND = 2035; +const int NWNX_UTIL_RESREF_TYPE_ENCOUNTER = 2040; +const int NWNX_UTIL_RESREF_TYPE_DOOR = 2042; +const int NWNX_UTIL_RESREF_TYPE_PLACEABLE = 2044; +const int NWNX_UTIL_RESREF_TYPE_STORE = 2051; +const int NWNX_UTIL_RESREF_TYPE_WAYPOINT = 2058; +///@} + +/// @brief A world time struct +struct NWNX_Util_WorldTime +{ + int nCalendarDay; ///< The calendar day + int nTimeOfDay; ///< The time of day +}; + +/// @brief Gets the name of the currently executing script. +/// @note If depth is > 0, it will return the name of the script that called this one via ExecuteScript(). +/// @param depth to seek the executing script. +/// @return The name of the currently executing script. +string NWNX_Util_GetCurrentScriptName(int depth = 0); + +/// @brief Gets a string that contains the ascii table. +/// @note The character at index 0 is a space. +/// @return A string that contains all characters at their position (e.g. 'A' at 65). +string NWNX_Util_GetAsciiTableString(); + +/// @brief Gets an integer hash of a string. +/// @param str The string to hash. +/// @return The hashed string as an integer. +int NWNX_Util_Hash(string str); + +/// @brief Gets the value of customTokenNumber. +/// @param customTokenNumber The token number to query. +/// @return The string representation of the token value. +string NWNX_Util_GetCustomToken(int customTokenNumber); + +/// @brief Convert an effect type to an itemproperty type. +/// @param e The effect to convert to an itemproperty. +/// @return The converted itemproperty. +itemproperty NWNX_Util_EffectToItemProperty(effect e); + +/// +/// @brief Convert an itemproperty type to an effect type. +/// @param ip The itemproperty to convert to an effect. +/// @return The converted effect. +effect NWNX_Util_ItemPropertyToEffect(itemproperty ip); + +/// @brief Strip any color codes from a string. +/// @param str The string to strip of color. +/// @return The new string without any color codes. +string NWNX_Util_StripColors(string str); + +/// @brief Determines if the supplied resref exists. +/// @param resref The resref to check. +/// @param type The @ref resref_types "Resref Type". +/// @return TRUE/FALSE +int NWNX_Util_IsValidResRef(string resref, int type = NWNX_UTIL_RESREF_TYPE_CREATURE); + +/// @brief Retrieves an environment variable. +/// @param sVarname The environment variable to query. +/// @return The value of the environment variable. +string NWNX_Util_GetEnvironmentVariable(string sVarname); + +/// @brief Gets the module real life minutes per in game hour. +/// @return The minutes per hour. +int NWNX_Util_GetMinutesPerHour(); + +/// @brief Set module real life minutes per in game hour. +/// @param minutes The minutes per hour. +void NWNX_Util_SetMinutesPerHour(int minutes); + +/// @anchor util_encode_url +/// @brief Encodes a string for usage in a URL. +/// @param str The string to encode for a URL. +/// @return The url encoded string. +string NWNX_Util_EncodeStringForURL(string str); + +/// @anchor twoda_row_count +/// @brief Gets the row count for a 2da. +/// @param str The 2da to check (do not include the .2da). +/// @return The amount of rows in the 2da. +int NWNX_Util_Get2DARowCount(string str); + +/// @brief Get the first resref of nType. +/// @param nType A @ref resref_types "Resref Type". +/// @param sRegexFilter Lets you filter out resrefs using a regexfilter. +/// For example: **nwnx_.\*** gets you all scripts prefixed with nwnx_ +/// when using the NSS resref type. +/// @param bModuleResourcesOnly If TRUE only custom resources will be returned. +/// @return The first resref found or "" if none is found. +string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter = "", int bModuleResourcesOnly = TRUE); + +/// @brief Get the next resref. +/// @return The next resref found or "" if none is found. +string NWNX_Util_GetNextResRef(); + +/// @brief Get the ticks per second of the server. +/// @remark Useful to dynamically detect lag and adjust behavior accordingly. +/// @return The ticks per second. +int NWNX_Util_GetServerTicksPerSecond(); + +/// @brief Get the last created object. +/// @param nObjectType Does not take the NWScript OBJECT_TYPE_* constants. +/// Use NWNX_Consts_TranslateNWScriptObjectType() to get their NWNX equivalent. +/// @param nNthLast The nth last object created. +/// @return The last created object. On error, this returns OBJECT_INVALID. +object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast = 1); + +/// @brief Compiles and adds a script to the UserDirectory/nwnx folder, or to the location of sAlias. +/// @note Will override existing scripts that are in the module. +/// @param sFileName The script filename without extension, 16 or less characters. +/// @param sScriptData The script data to compile +/// @param bWrapIntoMain Set to TRUE to wrap sScriptData into void main(){}. +/// @param sAlias The alias of the resource directory to add the ncs file to. Default: UserDirectory/nwnx +/// @return "" on success, or the compilation error. +string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain = FALSE, string sAlias = "NWNX"); + +/// @brief Gets the contents of a .nss script file as a string. +/// @param sScriptName The name of the script to get the contents of. +/// @param nMaxLength The max length of the return string, -1 to get everything +/// @return The script file contents or "" on error. +string NWNX_Util_GetNSSContents(string sScriptName, int nMaxLength = -1); + +/// @brief Adds a nss file to the UserDirectory/nwnx folder, or to the location of sAlias. +/// @note Will override existing nss files that are in the module +/// @param sFileName The script filename without extension, 16 or less characters. +/// @param sContents The contents of the nss file +/// @param sAlias The alias of the resource directory to add the nss file to. Default: UserDirectory/nwnx +/// @return TRUE on success. +int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias = "NWNX"); + +/// @brief Remove sFileName of nType from the UserDirectory/nwnx folder, or from the location of sAlias. +/// @param sFileName The filename without extension, 16 or less characters. +/// @param nType The @ref resref_types "Resref Type". +/// @param sAlias The alias of the resource directory to remove the file from. Default: UserDirectory/nwnx +/// @return TRUE on success. +int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias = "NWNX"); + +/// @brief Set the NWScript instruction limit. +/// @param nInstructionLimit The new limit or -1 to reset to default. +void NWNX_Util_SetInstructionLimit(int nInstructionLimit); + +/// @brief Get the NWScript instruction limit. +int NWNX_Util_GetInstructionLimit(); + +/// @brief Set the number of NWScript instructions currently executed. +/// @param nInstructions The number of instructions, must be >= 0. +void NWNX_Util_SetInstructionsExecuted(int nInstructions); + +/// @brief Get the number of NWScript instructions currently executed. +int NWNX_Util_GetInstructionsExecuted(); + +/// @brief Register a server console command that will execute a script chunk. +/// @note Example usage: NWNX_Util_RegisterServerConsoleCommand("test", "PrintString(\"Test Command -> Args: $args\");"); +/// @param sCommand The name of the command. +/// @param sScriptChunk The script chunk to run. You can use $args to get the console command arguments. +/// @return TRUE on success. +int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk); + +/// @brief Unregister a server console command that was registered with NWNX_Util_RegisterServerConsoleCommand(). +/// @param sCommand The name of the command. +void NWNX_Util_UnregisterServerConsoleCommand(string sCommand); + +/// @brief Determines if the given plugin exists and is enabled. +/// @param sPlugin The name of the plugin to check. This is the case sensitive plugin name as used by NWNX_CallFunction, NWNX_PushArgumentX +/// @note Example usage: NWNX_Util_PluginExists("NWNX_Creature"); +/// @return TRUE if the plugin exists and is enabled, otherwise FALSE. +int NWNX_Util_PluginExists(string sPlugin); + +/// @brief Gets the server's current working user folder. +/// @return The absolute path of the server's home directory (-userDirectory) +string NWNX_Util_GetUserDirectory(); + +/// @brief Get the return value of the last run script with a StartingConditional +/// @return Return value of the last run script. +int NWNX_Util_GetScriptReturnValue(); + +/// @brief Create a door. +/// @param sResRef The ResRef of the door. +/// @param locLocation The location to create the door at. +/// @param sNewTag An optional new tag for the door. +/// @param nAppearanceType An optional index into doortypes.2da for appearance. +/// @return The door, or OBJECT_INVALID on failure. +object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag = "", int nAppearanceType = -1); + +/// @brief Set the object that will be returned by GetItemActivator. +/// @param oObject An object. +void NWNX_Util_SetItemActivator(object oObject); + +/// @brief Get the world time as calendar day and time of day. +/// @note This function is useful for calculating effect expiry times. +/// @param fAdjustment An adjustment in seconds, 0.0f will return the current world time, +/// positive or negative values will return a world time in the future or past. +/// @return A NWNX_Util_WorldTime struct with the calendar day and time of day. +struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment = 0.0f); + +/// @brief Set a server-side resource override. +/// @param nResType A @ref resref_types "Resref Type". +/// @param sOldName The old resource name, 16 characters or less. +/// @param sNewName The new resource name or "" to clear a previous override, 16 characters or less. +void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName); + +/// @brief Get a server-side resource override. +/// @param nResType A @ref resref_types "Resref Type". +/// @param sName The name of the resource, 16 characters or less. +/// @return The resource override, or "" if one is not set. +string NWNX_Util_GetResourceOverride(int nResType, string sName); + +/// @brief Get if a script param is set. +/// @param sParamName The script parameter name to check. +/// @return TRUE if the script param is set, FALSE if not or on error. +int NWNX_Util_GetScriptParamIsSet(string sParamName); + +/// @brief Set the module dawn hour. +/// @param nDawnHour The new dawn hour +void NWNX_Util_SetDawnHour(int nDawnHour); + +/// @brief Set the module dusk hour. +/// @param nDuskHour The new dusk hour +void NWNX_Util_SetDuskHour(int nDuskHour); + +/// @} + +string NWNX_Util_GetCurrentScriptName(int depth = 0) +{ + string sFunc = "GetCurrentScriptName"; + NWNX_PushArgumentInt(NWNX_Util, sFunc, depth); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +string NWNX_Util_GetAsciiTableString() +{ + string sFunc = "GetAsciiTableString"; + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_Hash(string str) +{ + string sFunc = "Hash"; + NWNX_PushArgumentString(NWNX_Util, sFunc, str); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +string NWNX_Util_GetCustomToken(int customTokenNumber) +{ + string sFunc = "GetCustomToken"; + NWNX_PushArgumentInt(NWNX_Util, sFunc, customTokenNumber); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +itemproperty NWNX_Util_EffectToItemProperty(effect e) +{ + string sFunc = "EffectTypeCast"; + NWNX_PushArgumentEffect(NWNX_Util, sFunc, e); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueItemProperty(NWNX_Util, sFunc); +} + +effect NWNX_Util_ItemPropertyToEffect(itemproperty ip) +{ + string sFunc = "EffectTypeCast"; + NWNX_PushArgumentItemProperty(NWNX_Util, sFunc, ip); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueEffect(NWNX_Util, sFunc); +} + +string NWNX_Util_StripColors(string str) +{ + string sFunc = "StripColors"; + NWNX_PushArgumentString(NWNX_Util, sFunc, str); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_IsValidResRef(string resref, int type = NWNX_UTIL_RESREF_TYPE_CREATURE) +{ + string sFunc = "IsValidResRef"; + NWNX_PushArgumentInt(NWNX_Util, sFunc, type); + NWNX_PushArgumentString(NWNX_Util, sFunc, resref); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +string NWNX_Util_GetEnvironmentVariable(string sVarname) +{ + string sFunc = "GetEnvironmentVariable"; + NWNX_PushArgumentString(NWNX_Util, sFunc, sVarname); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_GetMinutesPerHour() +{ + string sFunc = "GetMinutesPerHour"; + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +void NWNX_Util_SetMinutesPerHour(int minutes) +{ + string sFunc = "SetMinutesPerHour"; + NWNX_PushArgumentInt(NWNX_Util, sFunc, minutes); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +string NWNX_Util_EncodeStringForURL(string sURL) +{ + string sFunc = "EncodeStringForURL"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sURL); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_Get2DARowCount(string str) +{ + string sFunc = "Get2DARowCount"; + NWNX_PushArgumentString(NWNX_Util, sFunc, str); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter = "", int bModuleResourcesOnly = TRUE) +{ + string sFunc = "GetFirstResRef"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, bModuleResourcesOnly); + NWNX_PushArgumentString(NWNX_Util, sFunc, sRegexFilter); + NWNX_PushArgumentInt(NWNX_Util, sFunc, nType); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +string NWNX_Util_GetNextResRef() +{ + string sFunc = "GetNextResRef"; + + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_GetServerTicksPerSecond() +{ + string sFunc = "GetServerTicksPerSecond"; + + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast = 1) +{ + string sFunc = "GetLastCreatedObject"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nNthLast); + NWNX_PushArgumentInt(NWNX_Util, sFunc, nObjectType); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Util, sFunc); +} + +string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain = FALSE, string sAlias = "NWNX") +{ + string sFunc = "AddScript"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sAlias); + NWNX_PushArgumentInt(NWNX_Util, sFunc, bWrapIntoMain); + NWNX_PushArgumentString(NWNX_Util, sFunc, sScriptData); + NWNX_PushArgumentString(NWNX_Util, sFunc, sFileName); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +string NWNX_Util_GetNSSContents(string sScriptName, int nMaxLength = -1) +{ + string sFunc = "GetNSSContents"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nMaxLength); + NWNX_PushArgumentString(NWNX_Util, sFunc, sScriptName); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias = "NWNX") +{ + string sFunc = "AddNSSFile"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sAlias); + NWNX_PushArgumentString(NWNX_Util, sFunc, sContents); + NWNX_PushArgumentString(NWNX_Util, sFunc, sFileName); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias = "NWNX") +{ + string sFunc = "RemoveNWNXResourceFile"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sAlias); + NWNX_PushArgumentInt(NWNX_Util, sFunc, nType); + NWNX_PushArgumentString(NWNX_Util, sFunc, sFileName); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +void NWNX_Util_SetInstructionLimit(int nInstructionLimit) +{ + string sFunc = "SetInstructionLimit"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nInstructionLimit); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +int NWNX_Util_GetInstructionLimit() +{ + string sFunc = "GetInstructionLimit"; + + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +void NWNX_Util_SetInstructionsExecuted(int nInstructions) +{ + string sFunc = "SetInstructionsExecuted"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nInstructions); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +int NWNX_Util_GetInstructionsExecuted() +{ + string sFunc = "GetInstructionsExecuted"; + + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk) +{ + string sFunc = "RegisterServerConsoleCommand"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sScriptChunk); + NWNX_PushArgumentString(NWNX_Util, sFunc, sCommand); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +void NWNX_Util_UnregisterServerConsoleCommand(string sCommand) +{ + string sFunc = "UnregisterServerConsoleCommand"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sCommand); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +int NWNX_Util_PluginExists(string sPlugin) +{ + string sFunc = "PluginExists"; + NWNX_PushArgumentString(NWNX_Util, sFunc, sPlugin); + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +string NWNX_Util_GetUserDirectory() +{ + string sFunc = "GetUserDirectory"; + NWNX_CallFunction(NWNX_Util, sFunc); + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_GetScriptReturnValue() +{ + string sFunc = "GetScriptReturnValue"; + + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag = "", int nAppearanceType = -1) +{ + string sFunc = "CreateDoor"; + + vector vPosition = GetPositionFromLocation(locLocation); + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nAppearanceType); + NWNX_PushArgumentString(NWNX_Util, sFunc, sNewTag); + NWNX_PushArgumentFloat(NWNX_Util, sFunc, GetFacingFromLocation(locLocation)); + NWNX_PushArgumentFloat(NWNX_Util, sFunc, vPosition.z); + NWNX_PushArgumentFloat(NWNX_Util, sFunc, vPosition.y); + NWNX_PushArgumentFloat(NWNX_Util, sFunc, vPosition.x); + NWNX_PushArgumentObject(NWNX_Util, sFunc, GetAreaFromLocation(locLocation)); + NWNX_PushArgumentString(NWNX_Util, sFunc, sResRef); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueObject(NWNX_Util, sFunc); +} + +void NWNX_Util_SetItemActivator(object oObject) +{ + string sFunc = "SetItemActivator"; + + NWNX_PushArgumentObject(NWNX_Util, sFunc, oObject); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment = 0.0f) +{ + string sFunc = "GetWorldTime"; + + NWNX_PushArgumentFloat(NWNX_Util, sFunc, fAdjustment); + NWNX_CallFunction(NWNX_Util, sFunc); + + struct NWNX_Util_WorldTime strWorldTime; + strWorldTime.nTimeOfDay = NWNX_GetReturnValueInt(NWNX_Util, sFunc); + strWorldTime.nCalendarDay = NWNX_GetReturnValueInt(NWNX_Util, sFunc); + + return strWorldTime; +} + +void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName) +{ + string sFunc = "SetResourceOverride"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sNewName); + NWNX_PushArgumentString(NWNX_Util, sFunc, sOldName); + NWNX_PushArgumentInt(NWNX_Util, sFunc, nResType); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +string NWNX_Util_GetResourceOverride(int nResType, string sName) +{ + string sFunc = "GetResourceOverride"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sName); + NWNX_PushArgumentInt(NWNX_Util, sFunc, nResType); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueString(NWNX_Util, sFunc); +} + +int NWNX_Util_GetScriptParamIsSet(string sParamName) +{ + string sFunc = "GetScriptParamIsSet"; + + NWNX_PushArgumentString(NWNX_Util, sFunc, sParamName); + NWNX_CallFunction(NWNX_Util, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Util, sFunc); +} + +void NWNX_Util_SetDawnHour(int nDawnHour) +{ + string sFunc = "SetDawnHour"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nDawnHour); + NWNX_CallFunction(NWNX_Util, sFunc); +} + +void NWNX_Util_SetDuskHour(int nDuskHour) +{ + string sFunc = "SetDuskHour"; + + NWNX_PushArgumentInt(NWNX_Util, sFunc, nDuskHour); + NWNX_CallFunction(NWNX_Util, sFunc); +} diff --git a/nwnds_module/nwnx_visibility.nss b/nwnds_module/nwnx_visibility.nss new file mode 100644 index 000000000..31406370d --- /dev/null +++ b/nwnds_module/nwnx_visibility.nss @@ -0,0 +1,77 @@ +/// @addtogroup visibility Visibility +/// @brief Functions to manipulate visibility of objects both globally or per observer +/// @{ +/// @file nwnx_visibility.nss +#include "nwnx" + +const string NWNX_Visibility = "NWNX_Visibility"; ///< @private + +/// @name Visibility Types +/// @anchor vis_types +/// @{ +const int NWNX_VISIBILITY_DEFAULT = -1; +const int NWNX_VISIBILITY_VISIBLE = 0; +const int NWNX_VISIBILITY_HIDDEN = 1; +const int NWNX_VISIBILITY_DM_ONLY = 2; +const int NWNX_VISIBILITY_ALWAYS_VISIBLE = 3; +const int NWNX_VISIBILITY_ALWAYS_VISIBLE_DM_ONLY = 4; +///@} + +/// @brief Queries the existing visibility override for given (oPlayer, oTarget) pair. +/// If oPlayer is OBJECT_INVALID, the global visibility override will be returned. +/// +/// * NWNX_VISIBILITY_DEFAULT = Override not set. +/// * NWNX_VISIBILITY_VISIBLE = Target is visible but still adheres to default visibility rules. +/// * NWNX_VISIBILITY_HIDDEN = Target is always hidden. +/// * NWNX_VISIBILITY_DM_ONLY = Target is only visible to DMs but still adheres to default visibility rules. +/// * NWNX_VISIBILITY_ALWAYS_VISIBLE = Target is always visible in all circumstances. +/// * NWNX_VISIBILITY_ALWAYS_VISIBLE_DM_ONLY = Target is always visible only to DMs in all circumstances. +/// +/// @param oPlayer The PC Object or OBJECT_INVALID. +/// @param oTarget The object for which we're querying the visibility override. +/// @return The @ref vis_types "Visibility Type". +int NWNX_Visibility_GetVisibilityOverride(object oPlayer, object oTarget); + +/// @brief Overrides the default visibility rules about how oPlayer perceives oTarget. +/// If oPlayer is OBJECT_INVALID, the global visibility override will be set. +/// +/// * NWNX_VISIBILITY_DEFAULT = Remove a set override. +/// * NWNX_VISIBILITY_VISIBLE = Target is visible but still adheres to default visibility rules. +/// * NWNX_VISIBILITY_HIDDEN = Target is always hidden. +/// * NWNX_VISIBILITY_DM_ONLY = Target is only visible to DMs but still adheres to default visibility rules. +/// * NWNX_VISIBILITY_ALWAYS_VISIBLE = Target is always visible in all circumstances. +/// * NWNX_VISIBILITY_ALWAYS_VISIBLE_DM_ONLY = Target is always visible to DMs in all circumstances. +/// +/// @warning Setting too many objects to ALWAYS_VISIBLE in an area will impact the performance of your players. Use sparingly. +/// +/// @note Player state overrides the global state which means if a global state is set +/// to NWNX_VISIBILITY_HIDDEN or NWNX_VISIBILITY_DM_ONLY but the player's state is +/// set to NWNX_VISIBILITY_VISIBLE for the target, the object will be visible to the player. +/// +/// @param oPlayer The PC Object or OBJECT_INVALID. +/// @param oTarget The object for which we're altering the visibility. +/// @param nOverride The visibility type from @ref vis_types "Visibility Types". +void NWNX_Visibility_SetVisibilityOverride(object oPlayer, object oTarget, int nOverride); + +/// @} + +int NWNX_Visibility_GetVisibilityOverride(object oPlayer, object oTarget) +{ + string sFunc = "GetVisibilityOverride"; + + NWNX_PushArgumentObject(NWNX_Visibility, sFunc, oTarget); + NWNX_PushArgumentObject(NWNX_Visibility, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Visibility, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Visibility, sFunc); +} + +void NWNX_Visibility_SetVisibilityOverride(object oPlayer, object oTarget, int nOverride) +{ + string sFunc = "SetVisibilityOverride"; + + NWNX_PushArgumentInt(NWNX_Visibility, sFunc, nOverride); + NWNX_PushArgumentObject(NWNX_Visibility, sFunc, oTarget); + NWNX_PushArgumentObject(NWNX_Visibility, sFunc, oPlayer); + NWNX_CallFunction(NWNX_Visibility, sFunc); +} diff --git a/nwnds_module/nwnx_weapon.nss b/nwnds_module/nwnx_weapon.nss new file mode 100644 index 000000000..6f57d15e3 --- /dev/null +++ b/nwnds_module/nwnx_weapon.nss @@ -0,0 +1,330 @@ +/// @addtogroup weapon Weapon +/// @brief Functions exposing additional weapon properties. +/// @{ +/// @file nwnx_weapon.nss +#include "nwnx" + +const string NWNX_Weapon = "NWNX_Weapon"; ///< @private + +/// @name Weapons Options +/// @anchor wpn_opts +/// +/// Options constants to be used with NWNX_Weapon_SetOption function. +/// @{ +const int NWNX_WEAPON_OPT_GRTFOCUS_AB_BONUS = 0; ///< Greater Focus Attack Bonus +const int NWNX_WEAPON_OPT_GRTSPEC_DAM_BONUS = 1; ///< Greater Specialization Damage Bonus +///@} + +// Get Event Data Constants +const int NWNX_WEAPON_GETDATA_DC = 0; ///< Get Devastating Critical Data + +// Set Event Data Constants +const int NWNX_WEAPON_SETDATA_DC_BYPASS = 0; ///< Set Devastating Critical Bypass + +/// Devastating critical event data +struct NWNX_Weapon_DevastatingCriticalEvent_Data +{ + object oWeapon; ///< The weapon used to cause the event. + object oTarget; ///< The target hit with a devastating critical. + int nDamage; ///< The damage points delivered. +}; + +/// @brief Set nFeat as weapon focus feat for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetWeaponFocusFeat(int nBaseItem, int nFeat); + +/// @brief Set required creature size for a weapon base item to be finessable. +/// @param nBaseItem The base item id. +/// @param nSize The creature size minimum to consider this weapon finessable. +void NWNX_Weapon_SetWeaponFinesseSize(int nBaseItem, int nSize); + +/// @brief Get required creature size for a weapon base item to be finessable. +/// @param nBaseItem The base item id. +int NWNX_Weapon_GetWeaponFinesseSize(int nBaseItem); + +/// @brief Set weapon base item to be considered as unarmed for weapon finesse feat. +/// @param nBaseItem The base item id. +void NWNX_Weapon_SetWeaponUnarmed(int nBaseItem); + +/// @brief Set a feat as weapon improved critical for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetWeaponImprovedCriticalFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as weapon specialization for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetWeaponSpecializationFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as epic weapon focus for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetEpicWeaponFocusFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as epic weapon specialization for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetEpicWeaponSpecializationFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as epic weapon overwhelming critical for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as epic weapon devastating critical for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as weapon of choice for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetWeaponOfChoiceFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as greater weapon specialization for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetGreaterWeaponSpecializationFeat(int nBaseItem, int nFeat); + +/// @brief Set a feat as greater weapon focus for a base item. +/// @param nBaseItem The base item id. +/// @param nFeat The feat to set. +void NWNX_Weapon_SetGreaterWeaponFocusFeat(int nBaseItem, int nFeat); + +/// @brief Set base item as monk weapon. +/// @note Requires activation of CombatModes plugin for Flurry of Blows. +/// @param nBaseItem The base item id. +void NWNX_Weapon_SetWeaponIsMonkWeapon(int nBaseItem); + +/// @brief Set plugin options. +/// @param nOption The option to change from @ref wpn_opts "Weapon Options". +/// @param nVal The new value of the option. +void NWNX_Weapon_SetOption(int nOption, int nVal); + +/// @brief Set Devastating Critical Event Script. +/// @param sScript The script to call when a Devastating Critical occurs. +void NWNX_Weapon_SetDevastatingCriticalEventScript(string sScript); + +/// @brief Get Devastating Critical Event Data. +/// @note This is only for use with the Devastating Critical Event Script. +/// @return An NWNX_Weapon_DevastatingCriticalEvent_Data struct. +struct NWNX_Weapon_DevastatingCriticalEvent_Data NWNX_Weapon_GetDevastatingCriticalEventData(); + +/// @brief Bypass Devastating Critical. +/// @note This is only for use with the Devastating Critical Event Script. +void NWNX_Weapon_BypassDevastatingCritical(); + +/// @brief Sets weapon to gain .5 strength bonus. +/// @param oWeapon Should be a melee weapon. +/// @param nEnable TRUE for bonus. FALSE to turn off bonus. +/// @param bPersist whether the two hand state should persist to the gff file. +void NWNX_Weapon_SetOneHalfStrength(object oWeapon, int nEnable, int bPersist = FALSE); + +/// @brief Gets if the weapon is set to gain addition .5 strength bonus +/// @param oWeapon the weapon +/// @return FALSE/0 if weapon is not receiving the bonus. TRUE/1 if it does. +int NWNX_Weapon_GetOneHalfStrength(object oWeapon); + +/// @} + +void NWNX_Weapon_SetWeaponFocusFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetWeaponFocusFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetEpicWeaponFocusFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetEpicWeaponFocusFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetGreaterWeaponFocusFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetGreaterWeaponFocusFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponFinesseSize(int nBaseItem, int nSize) +{ + string sFunc = "SetWeaponFinesseSize"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nSize); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +int NWNX_Weapon_GetWeaponFinesseSize(int nBaseItem) +{ + string sFunc = "GetWeaponFinesseSize"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponUnarmed(int nBaseItem) +{ + string sFunc = "SetWeaponUnarmed"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponIsMonkWeapon(int nBaseItem) +{ + string sFunc = "SetWeaponIsMonkWeapon"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponImprovedCriticalFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetWeaponImprovedCriticalFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponSpecializationFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetWeaponSpecializationFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetGreaterWeaponSpecializationFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetGreaterWeaponSpecializationFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetEpicWeaponSpecializationFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetEpicWeaponSpecializationFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetEpicWeaponOverwhelmingCriticalFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetEpicWeaponOverwhelmingCriticalFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetEpicWeaponDevastatingCriticalFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetEpicWeaponDevastatingCriticalFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetWeaponOfChoiceFeat(int nBaseItem, int nFeat) +{ + string sFunc = "SetWeaponOfChoiceFeat"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nFeat); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nBaseItem); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetOption(int nOption, int nVal) +{ + string sFunc = "SetOption"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nVal); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nOption); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_SetDevastatingCriticalEventScript(string sScript) +{ + string sFunc = "SetDevastatingCriticalEventScript"; + + NWNX_PushArgumentString(NWNX_Weapon, sFunc, sScript); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +void NWNX_Weapon_BypassDevastatingCritical() +{ + string sFunc = "SetEventData"; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, 1); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, NWNX_WEAPON_SETDATA_DC_BYPASS); + + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +struct NWNX_Weapon_DevastatingCriticalEvent_Data NWNX_Weapon_GetDevastatingCriticalEventData() +{ + string sFunc = "GetEventData"; + struct NWNX_Weapon_DevastatingCriticalEvent_Data data; + + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, NWNX_WEAPON_GETDATA_DC); + NWNX_CallFunction(NWNX_Weapon, sFunc); + + data.oWeapon = NWNX_GetReturnValueObject(NWNX_Weapon, sFunc); + data.oTarget = NWNX_GetReturnValueObject(NWNX_Weapon, sFunc); + data.nDamage = NWNX_GetReturnValueInt(NWNX_Weapon, sFunc); + + return data; +} + +void NWNX_Weapon_SetOneHalfStrength(object oWeapon, int nEnable, int bPersist = FALSE) +{ + string sFunc = "SetOneHalfStrength"; + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, bPersist); + NWNX_PushArgumentInt(NWNX_Weapon, sFunc, nEnable); + NWNX_PushArgumentObject(NWNX_Weapon, sFunc, oWeapon); + NWNX_CallFunction(NWNX_Weapon, sFunc); +} + +int NWNX_Weapon_GetOneHalfStrength(object oWeapon) +{ + string sFunc = "GetOneHalfStrength"; + NWNX_PushArgumentObject(NWNX_Weapon, sFunc, oWeapon); + NWNX_CallFunction(NWNX_Weapon, sFunc); + + return NWNX_GetReturnValueInt(NWNX_Weapon, sFunc); +} diff --git a/nwnds_module/nwnx_webhook.nss b/nwnds_module/nwnx_webhook.nss new file mode 100644 index 000000000..755b63210 --- /dev/null +++ b/nwnds_module/nwnx_webhook.nss @@ -0,0 +1,43 @@ +/// @addtogroup webhook Webhook +/// @brief Send messages to external entities through web hooks. +/// @{ +/// @file nwnx_webhook.nss +#include "nwnx" + +const string NWNX_WebHook = "NWNX_WebHook"; ///< @private + +/// @brief Send a slack compatible webhook. +/// @param host The web server to send the hook. +/// @param path The path to the hook. +/// @param message The message to dispatch. +/// @param username The username to display as the originator of the hook. +/// @param mrkdwn Set to false if you do not wish your message's markdown be parsed. +void NWNX_WebHook_SendWebHookHTTPS(string host, string path, string message, string username = "", int mrkdwn = 1); + +/// @brief Resends a webhook message after a defined delay. +/// +/// Handy when a submission is rate limited, since the message that the event sends in NWNX_Events_GetEventData +/// is already constructed. So it just resends the WebHook with an optional delay. +/// @param host The web server to send the hook. +/// @param path The path to the hook. +/// @param sMessage The message to dispatch. +/// @param delay The delay in seconds to send the message again. +void NWNX_WebHook_ResendWebHookHTTPS(string host, string path, string sMessage, float delay = 0.0f); + +/// @} + +void NWNX_WebHook_SendWebHookHTTPS(string host, string path, string message, string username = "", int mrkdwn = 1) +{ + string sFunc = "SendWebHookHTTPS"; + NWNX_PushArgumentInt(NWNX_WebHook, sFunc, mrkdwn); + NWNX_PushArgumentString(NWNX_WebHook, sFunc, username); + NWNX_PushArgumentString(NWNX_WebHook, sFunc, message); + NWNX_PushArgumentString(NWNX_WebHook, sFunc, path); + NWNX_PushArgumentString(NWNX_WebHook, sFunc, host); + NWNX_CallFunction(NWNX_WebHook, sFunc); +} + +void NWNX_WebHook_ResendWebHookHTTPS(string host, string path, string sMessage, float delay = 0.0f) +{ + DelayCommand(delay, NWNX_WebHook_SendWebHookHTTPS(host, path, sMessage)); +} diff --git a/nwnds_module/nwnx_webhook_rch.nss b/nwnds_module/nwnx_webhook_rch.nss new file mode 100644 index 000000000..3555ef71a --- /dev/null +++ b/nwnds_module/nwnx_webhook_rch.nss @@ -0,0 +1,159 @@ +/// @ingroup webhook +/// @file nwnx_webhook_rch.nss +/// @brief Create richer webhook messages suitable for Discord +#include "nwnx_webhook" + +/// @ingroup webhook +/// @brief For more information on these fields see https://birdie0.github.io/discord-webhooks-guide/ +/// @note URL fields may require NWNX_Util_EncodeStringForURL(). +struct NWNX_WebHook_Message { + string sUsername; ///< https://birdie0.github.io/discord-webhooks-guide/structure/username.html + string sText; ///< https://birdie0.github.io/discord-webhooks-guide/structure/content.html + string sAvatarURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/avatar_url.html + string sColor; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/color.html + string sAuthorName; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/author.html + string sAuthorURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/author.html + string sAuthorIconURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/author.html + string sTitle; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/title.html + string sURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/url.html + string sDescription; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/description.html + string sThumbnailURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/thumbnail.html + string sImageURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/image.html + string sFooterText; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/footer.html + string sFooterURL; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/footer.html + int iTimestamp; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/timestamp.html + string sField1Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField1Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField1Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField2Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField2Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField2Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField3Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField3Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField3Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField4Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField4Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField4Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField5Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField5Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField5Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField6Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField6Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField6Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField7Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField7Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField7Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField8Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField8Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField8Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField9Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField9Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField9Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField10Name; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + string sField10Value; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html + int iField10Inline; ///< https://birdie0.github.io/discord-webhooks-guide/structure/embed/fields.html +}; + +/// @private We don't need this to be a part of the docs. +/// @brief Helper function to convert 0 or 1 to false or true. +/// @param iBool The integer representation of the boolean. +/// @return The string representation (true or false) of the boolean. +string IntToBoolString(int iBool); + +/// @ingroup webhook +/// @brief Builds and sends a rich webhook message based on the constructed NWNX_WebHook_Message. +/// @param host The web server to send the hook. +/// @param path The path to the hook. +/// @param stMessage A constructed NWNX_Webhook_Message. +/// @param mrkdwn Set to false if you do not wish your message's markdown be parsed. +/// @warning Your path must end with /slack if using a Discord webhook. +string NWNX_WebHook_BuildMessageForWebHook(string host, string path, struct NWNX_WebHook_Message stMessage, int mrkdwn = 1); + +string IntToBoolString(int iBool) +{ + return iBool == 0 ? "false" : "true"; +} + +string NWNX_WebHook_BuildMessageForWebHook(string host, string path, struct NWNX_WebHook_Message stMessage, int mrkdwn = 1) +{ + if (host == "discordapp.com" && GetStringRight(path, 6) != "/slack") + { + PrintString("Discord WebHook specified but path does not end with /slack"); + return ""; + } + + // Open JSON + string message = "{"; + + string sMainText = ""; + + // The only way to turn off markdown for discord is to surround the text in backticks + if (stMessage.sText != "") + { + if (host == "discordapp.com" && !mrkdwn) + sMainText = "```text\\n" + stMessage.sText + "```"; + else + sMainText = stMessage.sText; + } + message = message + "\"text\": \"" + sMainText + "\""; + + // Slack will turn off markdown + if (host != "discordapp.com" && !mrkdwn) + message = message + ",\"mrkdwn\": false"; + + // Set the user attributes for the poster + if (stMessage.sUsername != "") + message = message + ",\"username\": \"" + stMessage.sUsername + "\""; + if (stMessage.sAvatarURL != "") + message = message + ",\"icon_url\": \"" + stMessage.sAvatarURL + "\""; + + // We need to construct an attachment (embed) object + if (stMessage.sAuthorName != "" || stMessage.sAuthorURL != "" || stMessage.sAuthorIconURL != "" || + stMessage.sTitle != "" || stMessage.sURL != "" || stMessage.sDescription != "" || + stMessage.sFooterText != "" || stMessage.sFooterURL != "" || stMessage.iTimestamp > 0 || + stMessage.sColor != "" || stMessage.sThumbnailURL != "" || stMessage.sImageURL != "" || stMessage.sField1Name != "") + { + message = message + ",\"attachments\": [{\"author_name\": \"" + stMessage.sAuthorName + "\",\"author_link\": \"" + stMessage.sAuthorURL + + "\",\"author_icon\": \"" + stMessage.sAuthorIconURL + "\",\"title\": \"" + stMessage.sTitle + "\",\"title_link\": \"" + stMessage.sURL + + "\",\"text\": \"" + stMessage.sDescription + "\",\"footer\": \"" + stMessage.sFooterText + "\",\"footer_icon\": \"" + stMessage.sFooterURL + + "\",\"color\": \"" + stMessage.sColor + "\",\"thumb_url\": \"" + stMessage.sThumbnailURL + + "\",\"image_url\": \"" + stMessage.sImageURL + "\""; + + // Dont post an empty timestamp + if (stMessage.iTimestamp > 0) + message = message + ",\"ts\": \"" + IntToString(stMessage.iTimestamp) + "\""; + + // Fields to handle + if (stMessage.sField1Name != "") + { + message = message + ",\"fields\": ["; + message = message + "{\"title\": \"" + stMessage.sField1Name + "\",\"value\": \"" + stMessage.sField1Value + "\",\"short\": " + IntToBoolString(stMessage.iField1Inline) + "}"; + if (stMessage.sField2Name != "") + message = message + ",{\"title\": \"" + stMessage.sField2Name + "\",\"value\": \"" + stMessage.sField2Value + "\",\"short\": " + IntToBoolString(stMessage.iField2Inline) + "}"; + if (stMessage.sField3Name != "") + message = message + ",{\"title\": \"" + stMessage.sField3Name + "\",\"value\": \"" + stMessage.sField3Value + "\",\"short\": " + IntToBoolString(stMessage.iField3Inline) + "}"; + if (stMessage.sField4Name != "") + message = message + ",{\"title\": \"" + stMessage.sField4Name + "\",\"value\": \"" + stMessage.sField4Value + "\",\"short\": " + IntToBoolString(stMessage.iField4Inline) + "}"; + if (stMessage.sField5Name != "") + message = message + ",{\"title\": \"" + stMessage.sField5Name + "\",\"value\": \"" + stMessage.sField5Value + "\",\"short\": " + IntToBoolString(stMessage.iField5Inline) + "}"; + if (stMessage.sField6Name != "") + message = message + ",{\"title\": \"" + stMessage.sField6Name + "\",\"value\": \"" + stMessage.sField6Value + "\",\"short\": " + IntToBoolString(stMessage.iField6Inline) + "}"; + if (stMessage.sField7Name != "") + message = message + ",{\"title\": \"" + stMessage.sField7Name + "\",\"value\": \"" + stMessage.sField7Value + "\",\"short\": " + IntToBoolString(stMessage.iField7Inline) + "}"; + if (stMessage.sField8Name != "") + message = message + ",{\"title\": \"" + stMessage.sField8Name + "\",\"value\": \"" + stMessage.sField8Value + "\",\"short\": " + IntToBoolString(stMessage.iField8Inline) + "}"; + if (stMessage.sField9Name != "") + message = message + ",{\"title\": \"" + stMessage.sField9Name + "\",\"value\": \"" + stMessage.sField9Value + "\",\"short\": " + IntToBoolString(stMessage.iField9Inline) + "}"; + if (stMessage.sField10Name != "") + message = message + ",{\"title\": \"" + stMessage.sField10Name + "\",\"value\": \"" + stMessage.sField10Value + "\",\"short\": " + IntToBoolString(stMessage.iField10Inline) + "}"; + // Close fields array + message = message + "]"; + } + // Close attachments array + message = message + "}]"; + } + // Close JSON + message = message + "}"; + + return message; +} diff --git a/nwnds_module/on_pubsub.ncs b/nwnds_module/on_pubsub.ncs new file mode 100644 index 000000000..2c7c3d2b2 Binary files /dev/null and b/nwnds_module/on_pubsub.ncs differ diff --git a/nwnds_module/on_pubsub.nss b/nwnds_module/on_pubsub.nss new file mode 100644 index 000000000..4505136a3 --- /dev/null +++ b/nwnds_module/on_pubsub.nss @@ -0,0 +1,14 @@ +/// @ingroup redis +/// @brief Script to handle PubSub event +/// @{ +/// @file on_pubsub.nss +#include "nwnx_redis_ps" + +void main() +{ + struct NWNX_Redis_PubSubMessageData data = NWNX_Redis_GetPubSubMessageData(); + + WriteTimestampedLogEntry("Pubsub Event: channel=" + data.channel + + " message=" + data.message); +} +/// @} diff --git a/nwnds_module/preai_default9.ncs b/nwnds_module/preai_default9.ncs index bfff35d0a..66681d97a 100644 Binary files a/nwnds_module/preai_default9.ncs and b/nwnds_module/preai_default9.ncs differ diff --git a/nwnds_module/race_sla.ncs b/nwnds_module/race_sla.ncs index 9ec2c3873..f63c3e584 100644 Binary files a/nwnds_module/race_sla.ncs and b/nwnds_module/race_sla.ncs differ diff --git a/nwnds_module/re_commonspwnrhb.ncs b/nwnds_module/re_commonspwnrhb.ncs index cfb4f6d0d..f7de25830 100644 Binary files a/nwnds_module/re_commonspwnrhb.ncs and b/nwnds_module/re_commonspwnrhb.ncs differ diff --git a/nwnds_module/re_mmorpghb.ncs b/nwnds_module/re_mmorpghb.ncs index ef345d01d..17c1ea391 100644 Binary files a/nwnds_module/re_mmorpghb.ncs and b/nwnds_module/re_mmorpghb.ncs differ diff --git a/nwnds_module/re_nightspawnhb.ncs b/nwnds_module/re_nightspawnhb.ncs index 72dfbae5b..aaef0a761 100644 Binary files a/nwnds_module/re_nightspawnhb.ncs and b/nwnds_module/re_nightspawnhb.ncs differ diff --git a/nwnds_module/re_pwrespawnerhb.ncs b/nwnds_module/re_pwrespawnerhb.ncs index 6c75c7be4..9aae8eb9d 100644 Binary files a/nwnds_module/re_pwrespawnerhb.ncs and b/nwnds_module/re_pwrespawnerhb.ncs differ diff --git a/nwnds_module/re_spawnerhb.ncs b/nwnds_module/re_spawnerhb.ncs index f8d423e05..66333d04f 100644 Binary files a/nwnds_module/re_spawnerhb.ncs and b/nwnds_module/re_spawnerhb.ncs differ diff --git a/nwnds_module/thegray.are b/nwnds_module/thegray.are index 37509c7cc..634413aaa 100644 Binary files a/nwnds_module/thegray.are and b/nwnds_module/thegray.are differ diff --git a/nwnds_module/tmp_m_airinc.ncs b/nwnds_module/tmp_m_airinc.ncs index 18c6dec25..00654f4d1 100644 Binary files a/nwnds_module/tmp_m_airinc.ncs and b/nwnds_module/tmp_m_airinc.ncs differ diff --git a/nwnds_notes/Erdlu_AC.txt b/nwnds_notes/Erdlu_AC.txt index 52647ef60..d7071d56e 100644 --- a/nwnds_notes/Erdlu_AC.txt +++ b/nwnds_notes/Erdlu_AC.txt @@ -16,7 +16,7 @@ PC Level Bonus HD Natural AC+ Str/Dex+ Feat Special Epic Progression: PC Level Bonus HD Natural AC+ Str/Dex+ Feat Special 21st-23rd +14 +14 +7 Blind-fight - -24th-26th +16 +16 +8 Imp Nat Armor - +24th-26th +16 +16 +8 Iron Will - 27th-29th +18 +18 +9 - - 30th-32nd +20 +20 +10 Gr. Fortitude - 33rd-35th +22 +22 +11 Rapid Metabolism -