diff --git a/src/NWNX/Plugins/DamagePlugin.cs b/src/NWNX/Plugins/DamagePlugin.cs index 20b25ed..85deae5 100644 --- a/src/NWNX/Plugins/DamagePlugin.cs +++ b/src/NWNX/Plugins/DamagePlugin.cs @@ -69,6 +69,7 @@ public static DamageEventData GetDamageEventData() data.iCustom17 = VM.NWNX.StackPopInt(); data.iCustom18 = VM.NWNX.StackPopInt(); data.iCustom19 = VM.NWNX.StackPopInt(); + data.iSpellId = VM.NWNX.StackPopInt(); return data; } @@ -312,6 +313,7 @@ public struct DamageEventData public int iCustom17; public int iCustom18; public int iCustom19; + public int iSpellId; } public struct AttackEventData diff --git a/src/NWNX/Plugins/HttpclientPlugin.cs b/src/NWNX/Plugins/HttpclientPlugin.cs new file mode 100644 index 0000000..bbeb6ca --- /dev/null +++ b/src/NWNX/Plugins/HttpclientPlugin.cs @@ -0,0 +1,109 @@ +using static NWN.Core.NWScript; + +namespace NWN.Core.NWNX +{ + [NWNXPlugin(NWNX_HTTPClient)] + public class HttpclientPlugin + { + public const string NWNX_HTTPClient = "NWNX_HTTPClient"; + + ///< @private + /// @name Request Types + /// @anchor request_types + /// + /// @{ + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_GET = 0; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_POST = 1; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_DELETE = 2; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_PATCH = 3; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_PUT = 4; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_OPTION = 5; + public const int NWNX_HTTPCLIENT_REQUEST_METHOD_HEAD = 6; + + ///@} + /// @name Content Types + /// @anchor content_types + /// + /// @{ + public const int NWNX_HTTPCLIENT_CONTENT_TYPE_HTML = 0; + public const int NWNX_HTTPCLIENT_CONTENT_TYPE_PLAINTEXT = 1; + public const int NWNX_HTTPCLIENT_CONTENT_TYPE_JSON = 2; + public const int NWNX_HTTPCLIENT_CONTENT_TYPE_FORM_URLENCODED = 3; + public const int NWNX_HTTPCLIENT_CONTENT_TYPE_XML = 4; + + ///@} + /// @name HTTP Authentication Types + /// @anchor auth_types + /// + /// @{ + public const int NWNX_HTTPCLIENT_AUTH_TYPE_NONE = 0; + public const int NWNX_HTTPCLIENT_AUTH_TYPE_BASIC = 1; + public const int NWNX_HTTPCLIENT_AUTH_TYPE_DIGEST = 2; + public const int NWNX_HTTPCLIENT_AUTH_TYPE_BEARER_TOKEN = 3; + + ///@} + /// A structure for an HTTP Client Request + /// Sends an http method to the given host. + /// The structured NWNX_HTTPClient_Request information. + /// A unique identifier for the request for later access in the REQUEST_ID event data. + public static int SendRequest(Request s) + { + const string sFunc = "SendRequest"; + VM.NWNX.SetFunction(NWNX_HTTPClient, sFunc); + VM.NWNX.StackPush(s.sHeaders); + VM.NWNX.StackPush(s.nPort); + VM.NWNX.StackPush(s.sAuthPassword); + VM.NWNX.StackPush(s.sAuthUserOrToken); + VM.NWNX.StackPush(s.nAuthType); + VM.NWNX.StackPush(s.sData); + VM.NWNX.StackPush(s.nContentType); + VM.NWNX.StackPush(s.sPath); + VM.NWNX.StackPush(s.sHost); + VM.NWNX.StackPush(s.nRequestMethod); + VM.NWNX.StackPush(s.sTag); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + /// Returns an NWNX_HTTP_Client_Request structure + /// The request id returned from NWNX_HTTPClient_SendRequest() + /// The structured NWNX_HTTPClient_Request information + public static Request GetRequest(int nRequestId) + { + const string sFunc = "GetRequest"; + VM.NWNX.SetFunction(NWNX_HTTPClient, sFunc); + VM.NWNX.StackPush(nRequestId); + VM.NWNX.Call(); + Request s = default; + s.sTag = VM.NWNX.StackPopString(); + s.nRequestMethod = VM.NWNX.StackPopInt(); + s.sHost = VM.NWNX.StackPopString(); + s.sPath = VM.NWNX.StackPopString(); + s.nContentType = VM.NWNX.StackPopInt(); + s.sData = VM.NWNX.StackPopString(); + s.nAuthType = VM.NWNX.StackPopInt(); + s.sAuthUserOrToken = VM.NWNX.StackPopString(); + s.sAuthPassword = VM.NWNX.StackPopString(); + s.nPort = VM.NWNX.StackPopInt(); + s.sHeaders = VM.NWNX.StackPopString(); + return s; + } + + // @} + } + + public struct Request + { + public int nRequestMethod; + public string sTag; + public string sHost; + public string sPath; + public string sData; + public int nContentType; + public int nAuthType; + public string sAuthUserOrToken; + public string sAuthPassword; + public int nPort; + public string sHeaders; + } +} diff --git a/src/NWNX/Plugins/ObjectPlugin.cs b/src/NWNX/Plugins/ObjectPlugin.cs index 93d3fc3..31ec20f 100644 --- a/src/NWNX/Plugins/ObjectPlugin.cs +++ b/src/NWNX/Plugins/ObjectPlugin.cs @@ -871,6 +871,39 @@ public static void SetTrapCreator(uint oObject, uint oCreator) VM.NWNX.Call(); } + /// Return the name of the object for nLanguage. + /// an object + /// A PLAYER_LANGUAGE constant. + /// Gender to use, 0 or 1. + /// The localized string. + public static string GetLocalizedName(uint oObject, int nLanguage, int nGender = 0) + { + const string sFunc = "GetLocalizedName"; + VM.NWNX.SetFunction(NWNX_Object, sFunc); + VM.NWNX.StackPush(nGender); + VM.NWNX.StackPush(nLanguage); + VM.NWNX.StackPush(oObject); + VM.NWNX.Call(); + return VM.NWNX.StackPopString(); + } + + /// Set the name of the object as set in the toolset for nLanguage. + /// @note You may have to SetName(oObject, "") for the translated string to show. + /// an object + /// New value to set + /// A PLAYER_LANGUAGE constant. + /// Gender to use, 0 or 1. + public static void SetLocalizedName(uint oObject, string sName, int nLanguage, int nGender = 0) + { + const string sFunc = "SetLocalizedName"; + VM.NWNX.SetFunction(NWNX_Object, sFunc); + VM.NWNX.StackPush(nGender); + VM.NWNX.StackPush(nLanguage); + VM.NWNX.StackPush(sName); + VM.NWNX.StackPush(oObject); + VM.NWNX.Call(); + } + // @} } diff --git a/src/NWNX/Plugins/PlayerPlugin.cs b/src/NWNX/Plugins/PlayerPlugin.cs index dd7f310..216a69b 100644 --- a/src/NWNX/Plugins/PlayerPlugin.cs +++ b/src/NWNX/Plugins/PlayerPlugin.cs @@ -627,10 +627,12 @@ public static void SetCreatureNameOverride(uint oPlayer, uint oCreature, string /// The player to display the text to. /// The creature to display the text above. /// The text to display. - public static void FloatingTextStringOnCreature(uint oPlayer, uint oCreature, string sText) + /// If TRUE, sText will be displayed in oPlayer's chat window. + public static void FloatingTextStringOnCreature(uint oPlayer, uint oCreature, string sText, int bChatWindow = TRUE) { const string sFunc = "FloatingTextStringOnCreature"; VM.NWNX.SetFunction(NWNX_Player, sFunc); + VM.NWNX.StackPush(bChatWindow); VM.NWNX.StackPush(sText); VM.NWNX.StackPush(oCreature); VM.NWNX.StackPush(oPlayer); @@ -806,6 +808,16 @@ public static void SetTlkOverride(uint oPlayer, int nStrRef, string sOverride, i VM.NWNX.Call(); } + /// Make the player reload it's TlkTable. + /// The player. + public static void ReloadTlk(uint oPlayer) + { + const string sFunc = "ReloadTlk"; + VM.NWNX.SetFunction(NWNX_Player, sFunc); + VM.NWNX.StackPush(oPlayer); + VM.NWNX.Call(); + } + /// Update wind for oPlayer only. /// The player. /// The Wind's direction. @@ -920,6 +932,16 @@ public static uint GetTURD(uint oPlayer) return VM.NWNX.StackPopObject(); } + /// Reloads the color palettes for oPlayer + /// The player to reload the color palette for + public static void ReloadColorPalettes(uint oPlayer) + { + const string sFunc = "ReloadColorPalettes"; + VM.NWNX.SetFunction(NWNX_Player, sFunc); + VM.NWNX.StackPush(oPlayer); + VM.NWNX.Call(); + } + // @} public static void INTERNAL_StopGuiTimingBar(uint player, string script = "", int id = -1) { diff --git a/src/NWNX/Plugins/SqlPlugin.cs b/src/NWNX/Plugins/SqlPlugin.cs index 4197228..292e814 100644 --- a/src/NWNX/Plugins/SqlPlugin.cs +++ b/src/NWNX/Plugins/SqlPlugin.cs @@ -149,6 +149,15 @@ public static void PreparedNULL(int position) VM.NWNX.Call(); } + /// Set the Json value of a prepared statement at given position. + /// Convienence function to match other Prepared(type) functions. + /// The nth ? in a prepared statement. + /// The value to set. + public static void PreparedJson(int position, System.IntPtr value) + { + PreparedString(position, JsonDump(value)); + } + /// Like NWNX_SQL_ReadDataInActiveRow, but for full serialized objects. /// /// The object will be deserialized and created in the game. New object ID is returned. diff --git a/src/NWNX/Plugins/StorePlugin.cs b/src/NWNX/Plugins/StorePlugin.cs new file mode 100644 index 0000000..dfc9e72 --- /dev/null +++ b/src/NWNX/Plugins/StorePlugin.cs @@ -0,0 +1,111 @@ +using static NWN.Core.NWScript; + +namespace NWN.Core.NWNX +{ + [NWNXPlugin(NWNX_Store)] + public class StorePlugin + { + public const string NWNX_Store = "NWNX_Store"; + + ///< @private + /// Return status of a base item purchase status. + /// The store object. + /// A BASE_ITEM_* value + /// TRUE if the quest has been completed. -1 if the player does not have the journal entry. + public static int GetIsRestrictedBuyItem(uint oStore, int nBaseItem) + { + const string sFunc = "GetIsRestrictedBuyItem"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(nBaseItem); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + /// Return the blackmarket mark down of a store + /// The store object. + /// mark down of a store, -1 on error + public static int GetBlackMarketMarkDown(uint oStore) + { + const string sFunc = "GetBlackMarketMarkDown"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + /// Set the blackmarket mark down of a store + /// The store object. + /// The amount. + public static void SetBlackMarketMarkDown(uint oStore, int nValue) + { + const string sFunc = "SetBlackMarketMarkDown"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(nValue); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + } + + /// Return the mark down of a store + /// The store object. + /// mark down of a store, -1 on error + public static int GetMarkDown(uint oStore) + { + const string sFunc = "GetMarkDown"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + /// Set the mark down of a store + /// The store object. + /// The amount. + public static void SetMarkDown(uint oStore, int nValue) + { + const string sFunc = "SetMarkDown"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(nValue); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + } + + /// Return the mark up of a store + /// The store object. + /// mark up of a store, -1 on error + public static int GetMarkUp(uint oStore) + { + const string sFunc = "GetMarkUp"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + /// Set the mark up of a store + /// The store object. + /// The amount. + public static void SetMarkUp(uint oStore, int nValue) + { + const string sFunc = "SetMarkUp"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(nValue); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + } + + /// Return current customer count + /// The store object. + /// count, or -1 on error + public static int GetCurrentCustomersCount(uint oStore) + { + const string sFunc = "GetCurrentCustomersCount"; + VM.NWNX.SetFunction(NWNX_Store, sFunc); + VM.NWNX.StackPush(oStore); + VM.NWNX.Call(); + return VM.NWNX.StackPopInt(); + } + + // @} + } +} diff --git a/src/NWNX/Plugins/UtilPlugin.cs b/src/NWNX/Plugins/UtilPlugin.cs index 2eba01c..fa2cec8 100644 --- a/src/NWNX/Plugins/UtilPlugin.cs +++ b/src/NWNX/Plugins/UtilPlugin.cs @@ -546,6 +546,16 @@ public static int CleanResourceDirectory(string sAlias, int nResType = 65535) return VM.NWNX.StackPopInt(); } + /// Return the filename of the tlk file. + /// The name + public static string GetModuleTlkFile() + { + const string sFunc = "GetModuleTlkFile"; + VM.NWNX.SetFunction(NWNX_Util, sFunc); + VM.NWNX.Call(); + return VM.NWNX.StackPopString(); + } + // @} }