Esempio n. 1
0
 /// <summary>
 /// Signals an event. This will dispatch a notification to all subscribed handlers.
 /// Returns TRUE if anyone was subscribed to the event, FALSE otherwise.
 /// </summary>
 /// <param name="evt"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public static int SignalEvent(string evt, NWGameObject target)
 {
     NWNXCore.NWNX_PushArgumentObject("NWNX_Events", "SIGNAL_EVENT", target);
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "SIGNAL_EVENT", evt);
     NWNXCore.NWNX_CallFunction("NWNX_Events", "SIGNAL_EVENT");
     return(NWNXCore.NWNX_GetReturnValueInt("NWNX_Events", "SIGNAL_EVENT"));
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Get obj's appearance
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static int GetAppearance(NWGameObject obj)
        {
            string sFunc = "GetAppearance";

            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
            return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the count of all local variables on the provided object.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static int GetLocalVariableCount(NWGameObject obj)
        {
            string sFunc = "GetLocalVariableCount";

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

            return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc));
        }
Esempio n. 5
0
        /// <summary>
        /// Return damage immunity (in percent) against given damage type
        /// Use DAMAGE_TYPE_* constants for damageType
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="damageType"></param>
        /// <returns></returns>
        public static int GetDamageImmunity(NWGameObject obj, int damageType)
        {
            string sFunc = "GetDamageImmunity";

            NWNXCore.NWNX_PushArgumentInt(NWNX_Object, sFunc, damageType);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);

            return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc));
        }
Esempio n. 6
0
        /// <summary>
        /// Return true if an item of baseitem type can fit in object's inventory
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="baseitem"></param>
        /// <returns></returns>
        public static bool CheckFit(NWGameObject item, int baseitem)
        {
            string sFunc = "CheckFit";

            NWNXCore.NWNX_PushArgumentInt(NWNX_Object, sFunc, baseitem);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, item);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);

            return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc) == 1);
        }
Esempio n. 7
0
        /// <summary>
        /// Return true if obj has visual effect nVFX applied to it
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="nVFX"></param>
        /// <returns></returns>
        public static bool GetHasVisualEffect(NWGameObject obj, int nVFX)
        {
            string sFunc = "GetHasVisualEffect";

            NWNXCore.NWNX_PushArgumentInt(NWNX_Object, sFunc, nVFX);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);

            return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Object, sFunc) == 1);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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)
            });
        }
Esempio n. 10
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)
            });
        }