Exemplo n.º 1
0
        public static ItemPropertyUnpacked UnpackIP(ItemProperty ip)
        {
            const string FunctionName = "UnpackIP";

            NWNXCore.NWNX_PushArgumentItemProperty(NWNX_ItemProperty, FunctionName, ip);
            NWNXCore.NWNX_CallFunction(NWNX_ItemProperty, FunctionName);

            var n = new ItemPropertyUnpacked
            {
                ItemPropertyID = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                Property       = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                SubType        = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                CostTable      = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                CostTableValue = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                Param1         = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                Param1Value    = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                UsesPerDay     = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                ChanceToAppear = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                IsUseable      = Convert.ToBoolean(NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName)),
                SpellID        = NWNXCore.NWNX_GetReturnValueInt(NWNX_ItemProperty, FunctionName),
                Creator        = NWNXCore.NWNX_GetReturnValueObject(NWNX_ItemProperty, FunctionName),
                Tag            = NWNXCore.NWNX_GetReturnValueString(NWNX_ItemProperty, FunctionName)
            };

            return(n);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the dialog resref of the object.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string GetDialogResref(NWGameObject obj)
        {
            string sFunc = "GetDialogResref";

            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
            return(NWNXCore.NWNX_GetReturnValueString(NWNX_Object, sFunc));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Serialize the full object (including locals, inventory, etc) to base64 string
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string Serialize(NWGameObject obj)
        {
            string sFunc = "Serialize";

            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
            return(NWNXCore.NWNX_GetReturnValueString(NWNX_Object, sFunc));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a local variable at the specified index.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static LocalVariable GetLocalVariable(NWGameObject obj, int index)
        {
            string sFunc = "GetLocalVariable";

            NWNXCore.NWNX_PushArgumentInt(NWNX_Object, sFunc, index);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);
            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);

            LocalVariable var = new LocalVariable();

            var.Key  = NWNXCore.NWNX_GetReturnValueString(NWNX_Object, sFunc);
            var.Type = (LocalVariableType)NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc);
            return(var);
        }
Exemplo n.º 5
0
        /// @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.
        public static ItemPropertyUnpacked GetActiveProperty(uint oItem, int nIndex)
        {
            const string sFunc = "GetActiveProperty";

            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, nIndex);
            NWNXCore.NWNX_PushArgumentObject(PLUGIN_NAME, sFunc, oItem);
            NWNXCore.NWNX_CallFunction(PLUGIN_NAME, sFunc);

            return(new ItemPropertyUnpacked
            {
                Property = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                SubType = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                CostTable = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                CostTableValue = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                Param1 = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                Param1Value = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                UsesPerDay = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                ChanceToAppear = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc),
                IsUseable = Convert.ToBoolean(NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, sFunc)),
                Tag = NWNXCore.NWNX_GetReturnValueString(PLUGIN_NAME, sFunc)
            });
        }
Exemplo n.º 6
0
        // Convert native itemproperty type to unpacked structure
        public static ItemPropertyUnpacked UnpackIP(Core.ItemProperty ip)
        {
            const string func = "UnpackIP";

            NWNXCore.NWNX_PushArgumentItemProperty(PLUGIN_NAME, func, ip);
            NWNXCore.NWNX_CallFunction(PLUGIN_NAME, func);

            return(new ItemPropertyUnpacked
            {
                Property = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                SubType = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                CostTable = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                CostTableValue = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                Param1 = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                Param1Value = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                UsesPerDay = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                ChanceToAppear = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                IsUseable = Convert.ToBoolean(NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func)),
                SpellID = NWNXCore.NWNX_GetReturnValueInt(PLUGIN_NAME, func),
                Creator = NWNXCore.NWNX_GetReturnValueObject(PLUGIN_NAME, func),
                Tag = NWNXCore.NWNX_GetReturnValueString(PLUGIN_NAME, func)
            });
        }
Exemplo n.º 7
0
 /// <summary>
 /// Retrieves the event data for the currently executing script.
 /// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER.
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetEventDataString(string tag)
 {
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "GET_EVENT_DATA", tag);
     NWNXCore.NWNX_CallFunction("NWNX_Events", "GET_EVENT_DATA");
     return(NWNXCore.NWNX_GetReturnValueString("NWNX_Events", "GET_EVENT_DATA"));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Returns the current event name
 /// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER.
 /// </summary>
 /// <returns></returns>
 public static string GetCurrentEvent()
 {
     NWNXCore.NWNX_CallFunction("NWNX_Events", "GET_CURRENT_EVENT");
     return(NWNXCore.NWNX_GetReturnValueString("NWNX_Events", "GET_CURRENT_EVENT"));
 }