示例#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"));
 }
示例#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);
        }
示例#3
0
        /// <summary>
        /// Returns an object from the provided object ID.
        /// This is the counterpart to ObjectToString.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static NWGameObject StringToObject(string id)
        {
            string sFunc = "StringToObject";

            NWNXCore.NWNX_PushArgumentString(NWNX_Object, sFunc, id);
            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
            return(NWNXCore.NWNX_GetReturnValueObject(NWNX_Object, sFunc));
        }
示例#4
0
        /// <summary>
        /// Deserialize the object. The object will be created outside of the world and
        /// needs to be manually positioned at a location/inventory.
        /// </summary>
        /// <param name="serialized"></param>
        /// <returns></returns>
        public static NWGameObject Deserialize(string serialized)
        {
            string sFunc = "Deserialize";

            NWNXCore.NWNX_PushArgumentString(NWNX_Object, sFunc, serialized);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
            return(NWNXCore.NWNX_GetReturnValueObject(NWNX_Object, sFunc));
        }
示例#5
0
        /// <summary>
        /// Set object's maximum hit points; will not work on PCs.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="hp"></param>
        public static void SetMaxHitPoints(NWGameObject creature, int hp)
        {
            string sFunc = "SetMaxHitPoints";

            NWNXCore.NWNX_PushArgumentInt(NWNX_Object, sFunc, hp);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, creature);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
        }
示例#6
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));
        }
示例#7
0
        /// <summary>
        /// Set obj's appearance. Will not update for PCs until they
        /// re-enter the area.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="app"></param>
        public static void SetAppearance(NWGameObject obj, int app)
        {
            string sFunc = "SetAppearance";

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

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
        }
示例#8
0
        /// <summary>
        /// Sets the dialog resref of the object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="dialog"></param>
        public static void SetDialogResref(NWGameObject obj, string dialog)
        {
            string sFunc = "SetDialogResref";

            NWNXCore.NWNX_PushArgumentString(NWNX_Object, sFunc, dialog);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);

            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
        }
示例#9
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));
        }
示例#10
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));
        }
示例#11
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));
        }
示例#12
0
        /// <summary>
        /// Set the provided object's position to the provided vector.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="pos"></param>
        public static void SetPosition(NWGameObject obj, Vector pos)
        {
            string sFunc = "SetPosition";

            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.X);
            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.Y);
            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.Z);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);
            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
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));
        }
示例#16
0
        /// <summary>
        /// Add or move obj to area at pos
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="area"></param>
        /// <param name="pos"></param>
        public static void AddToArea(NWGameObject obj, NWGameObject area, Vector pos)
        {
            string sFunc = "AddToArea";

            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.Z);
            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.Y);
            NWNXCore.NWNX_PushArgumentFloat(NWNX_Object, sFunc, pos.X);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, area);
            NWNXCore.NWNX_PushArgumentObject(NWNX_Object, sFunc, obj);
            NWNXCore.NWNX_CallFunction(NWNX_Object, sFunc);
        }
示例#17
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);
        }
示例#18
0
        // Convert unpacked itemproperty structure to native type.
        public static Core.ItemProperty PackIP(ItemPropertyUnpacked itemProperty)
        {
            const string sFunc = "PackIP";

            NWNXCore.NWNX_PushArgumentString(PLUGIN_NAME, sFunc, itemProperty.Tag);
            NWNXCore.NWNX_PushArgumentObject(PLUGIN_NAME, sFunc, itemProperty.Creator);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.SpellID);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.IsUseable ? 1 : 0);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.ChanceToAppear);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.UsesPerDay);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.Param1Value);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.Param1);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.CostTableValue);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.CostTable);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.SubType);
            NWNXCore.NWNX_PushArgumentInt(PLUGIN_NAME, sFunc, itemProperty.Property);

            NWNXCore.NWNX_CallFunction(PLUGIN_NAME, sFunc);
            return(NWNXCore.NWNX_GetReturnValueItemProperty(PLUGIN_NAME, sFunc));
        }
示例#19
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)
            });
        }
示例#20
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)
            });
        }
示例#21
0
 /// <summary>
 ///
 /// 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
 /// - Healer's Kit event
 /// - CombatMode events
 /// - Party events
 /// - Skill events
 /// - Map events
 /// - Listen/Spot Detection events
 /// - Polymorph events
 /// - DMAction events
 /// - Client connect event
 /// - Spell events
 /// - QuickChat events
 /// - Barter event (START only)
 /// - Trap events
 /// - Sticky Player Name event
 /// </summary>
 public static void SkipEvent()
 {
     NWNXCore.NWNX_CallFunction("NWNX_Events", "SKIP_EVENT");
 }
示例#22
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"));
 }
示例#23
0
 /// <summary>
 /// Pushes event data at the provided tag, which subscribers can access with GetEventData.
 /// This should be called BEFORE SignalEvent.
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="data"></param>
 public static void PushEventData(string tag, string data)
 {
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "PUSH_EVENT_DATA", data);
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "PUSH_EVENT_DATA", tag);
     NWNXCore.NWNX_CallFunction("NWNX_Events", "PUSH_EVENT_DATA");
 }
示例#24
0
 /// <summary>
 /// 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 (see NWNX_Events_SignalEvent).
 /// </summary>
 /// <param name="evt"></param>
 /// <param name="script"></param>
 public static void SubscribeEvent(string evt, string script)
 {
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "SUBSCRIBE_EVENT", script);
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "SUBSCRIBE_EVENT", evt);
     NWNXCore.NWNX_CallFunction("NWNX_Events", "SUBSCRIBE_EVENT");
 }
示例#25
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"));
 }
示例#26
0
 /// <summary>
 /// Set the return value of the event.
 ///
 /// THIS SHOULD ONLY BE CALLED FROM WITHIN AN EVENT HANDLER.
 /// ONLY WORKS WITH THE FOLLOWING EVENTS:
 /// - 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"
 /// </summary>
 /// <param name="data"></param>
 public static void SetEventResult(string data)
 {
     NWNXCore.NWNX_PushArgumentString("NWNX_Events", "EVENT_RESULT", data);
     NWNXCore.NWNX_CallFunction("NWNX_Events", "EVENT_RESULT");
 }