/// <summary> /// Gets the player's quickbar slot info /// </summary> /// <param name="player"></param> /// <param name="slot"></param> /// <returns></returns> public static QuickBarSlot GetQuickBarSlot(NWGameObject player, int slot) { string sFunc = "GetQuickBarSlot"; QuickBarSlot qbs = new QuickBarSlot(); NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, slot); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); qbs.Associate = (NWNXCore.NWNX_GetReturnValueObject(NWNX_Player, sFunc)); qbs.AssociateType = NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.DomainLevel = NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.MetaType = NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.INTParam1 = NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.ToolTip = NWNXCore.NWNX_GetReturnValueString(NWNX_Player, sFunc); qbs.CommandLine = NWNXCore.NWNX_GetReturnValueString(NWNX_Player, sFunc); qbs.CommandLabel = NWNXCore.NWNX_GetReturnValueString(NWNX_Player, sFunc); qbs.Resref = NWNXCore.NWNX_GetReturnValueString(NWNX_Player, sFunc); qbs.MultiClass = NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.ObjectType = (QuickBarSlotType)NWNXCore.NWNX_GetReturnValueInt(NWNX_Player, sFunc); qbs.SecondaryItem = (NWNXCore.NWNX_GetReturnValueObject(NWNX_Player, sFunc)); qbs.Item = (NWNXCore.NWNX_GetReturnValueObject(NWNX_Player, sFunc)); return(qbs); }
/// <summary> /// Starts displaying a timing bar. /// Will run a script at the end of the timing bar, if specified. /// </summary> /// <param name="creature">The creature who will see the timing bar.</param> /// <param name="seconds">How long the timing bar should come on screen.</param> /// <param name="script">The script to run at the end of the timing bar.</param> public static void StartGuiTimingBar(NWGameObject creature, float seconds, string script) { // only one timing bar at a time! if (_.GetLocalInt(creature, "NWNX_PLAYER_GUI_TIMING_ACTIVE") == 1) { return; } string sFunc = "StartGuiTimingBar"; NWNXCore.NWNX_PushArgumentFloat(NWNX_Player, sFunc, seconds); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, creature); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); int id = _.GetLocalInt(creature, "NWNX_PLAYER_GUI_TIMING_ID") + 1; _.SetLocalInt(creature, "NWNX_PLAYER_GUI_TIMING_ACTIVE", id); _.SetLocalInt(creature, "NWNX_PLAYER_GUI_TIMING_ID", id); _.DelayCommand(seconds, () => { StopGuiTimingBar(creature, script, -1); }); }
/// <summary> /// Stops displaying a timing bar. /// Runs a script if specified. /// </summary> /// <param name="creature">The creature's timing bar to stop.</param> /// <param name="script">The script to run once ended.</param> /// <param name="id">ID number of this timing bar.</param> public static void StopGuiTimingBar(NWGameObject creature, string script, int id) { int activeId = _.GetLocalInt(creature, "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(creature, "NWNX_PLAYER_GUI_TIMING_ACTIVE"); string sFunc = "StopGuiTimingBar"; NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, creature); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); if (!string.IsNullOrWhiteSpace(script)) { _.ExecuteScript(script, creature); } }
/// <summary> /// Set the PVP setting of area /// </summary> /// <param name="area"></param> /// <param name="pvpSetting"></param> public static void SetPVPSetting(NWGameObject area, AreaPVPSetting pvpSetting) { string sFunc = "SetPVPSetting"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, (int)pvpSetting); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Set the day/night cycle of area /// </summary> /// <param name="area"></param> /// <param name="type"></param> public static void SetDayNightCycle(NWGameObject area, AreaDayNightCycle type) { string sFunc = "SetDayNightCycle"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, (int)type); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Set the shadow opacity of area /// shadowOpacity = 0-100 /// </summary> /// <param name="area"></param> /// <param name="shadowOpacity"></param> public static void SetShadowOpacity(NWGameObject area, int shadowOpacity) { string sFunc = "SetShadowOpacity"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, shadowOpacity); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Set the fog clip distance in area /// </summary> /// <param name="area"></param> /// <param name="distance"></param> public static void SetFogClipDistance(NWGameObject area, float distance) { string sFunc = "SetFogClipDistance"; NWNXCore.NWNX_PushArgumentFloat(NWNX_Area, sFunc, distance); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Set the wind power in area /// windPower = 0-2 /// </summary> /// <param name="area"></param> /// <param name="windPower"></param> public static void SetWindPower(NWGameObject area, int windPower) { string sFunc = "SetWindPower"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, windPower); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Get the name of the .bic file associated with the player's character. /// </summary> /// <param name="player"></param> /// <returns></returns> public static string GetBicFileName(NWGameObject player) { string sFunc = "GetBicFileName"; NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); return(NWNXCore.NWNX_GetReturnValueString(NWNX_Player, sFunc)); }
/// <summary> /// Set the listen modifer of area /// </summary> /// <param name="area"></param> /// <param name="listenModifier"></param> public static void SetAreaListenModifier(NWGameObject area, int listenModifier) { string sFunc = "SetAreaListenModifier"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, listenModifier); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// Set whether resting is allowed in area /// true: Resting not allowed /// false: Resting allowed /// </summary> /// <param name="area"></param> /// <param name="bNoRestingAllowed"></param> public static void SetNoRestingAllowed(NWGameObject area, bool bNoRestingAllowed) { string sFunc = "SetNoRestingAllowed"; NWNXCore.NWNX_PushArgumentInt(NWNX_Area, sFunc, bNoRestingAllowed ? 1 : 0); NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); }
/// <summary> /// // Refreshes the players character sheet /// 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 /// </summary> /// <param name="player"></param> public static void UpdateCharacterSheet(NWGameObject player) { string sFunc = "UpdateCharacterSheet"; NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
// Restore an item's appearance with the value returned by GetEntireItemAppearance(). public static void RestoreItemAppearance(NWGameObject oItem, string sApp) { string sFunc = "RestoreItemAppearance"; NWNXCore.NWNX_PushArgumentString(NWNX_Item, sFunc, sApp); NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); }
// Return a String containing the entire appearance for oItem which can later be // passed to RestoreItemAppearance(). public static string GetEntireItemAppearance(NWGameObject oItem) { string sFunc = "GetEntireItemAppearance"; NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); return(NWNXCore.NWNX_GetReturnValueString(NWNX_Item, sFunc)); }
/// <summary> /// Get the PVP setting of area /// </summary> /// <param name="area"></param> /// <returns></returns> public static AreaPVPSetting GetPVPSetting(NWGameObject area) { string sFunc = "GetPVPSetting"; NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); return((AreaPVPSetting)NWNXCore.NWNX_GetReturnValueInt(NWNX_Area, sFunc)); }
/// <summary> /// Get the spot modifier of area /// </summary> /// <param name="area"></param> /// <returns></returns> public static int GetAreaSpotModifier(NWGameObject area) { string sFunc = "GetAreaSpotModifier"; NWNXCore.NWNX_PushArgumentObject(NWNX_Area, sFunc, area); NWNXCore.NWNX_CallFunction(NWNX_Area, sFunc); return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Area, sFunc)); }
/// <summary> /// Override oPlayer's rest animation to nAnimation /// /// NOTE: nAnimation does not take ANIMATION_LOOPING_* or ANIMATION_FIREFORGET_* constants /// Use NWNX_Consts_TranslateNWScriptAnimation() in nwnx_consts.nss to get their NWNX equivalent /// -1 to clear the override /// </summary> /// <param name="oPlayer">The player object</param> /// <param name="nAnimation">The rest animation</param> public static void SetRestAnimation(NWGameObject oPlayer, int nAnimation) { string sFunc = "SetRestAnimation"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, nAnimation); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, oPlayer); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
/// <summary> /// Override player's rest duration /// Duration is in milliseconds, 1000 = 1 second /// Minimum duration of 10ms /// -1 clears the override /// </summary> /// <param name="player"></param> /// <param name="duration"></param> public static void SetRestDuration(NWGameObject player, int duration) { string sFunc = "SetRestDuration"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, duration); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
/// <summary> /// Force opens the target object's inventory for the player. /// A few notes about this function: /// - 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. /// </summary> /// <param name="player"></param> /// <param name="placeable"></param> public static void ForcePlaceableInventoryWindow(NWGameObject player, NWGameObject placeable) { string sFunc = "ForcePlaceableInventoryWindow"; NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, placeable); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
// Set oItem's weight. Will not persist through saving. public static void SetWeight(NWGameObject oItem, int w) { string sFunc = "SetWeight"; NWNXCore.NWNX_PushArgumentInt(NWNX_Item, sFunc, w); NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); }
// Get oItem's additional value in gold pieces. public static int GetAddGoldPieceValue(NWGameObject oItem) { string sFunc = "GetAddGoldPieceValue"; NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Item, sFunc)); }
public static int GetBaseArmorClass(NWGameObject oItem) { string sFunc = "GetBaseArmorClass"; NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); return(NWNXCore.NWNX_GetReturnValueInt(NWNX_Item, sFunc)); }
/// <summary> /// /// Overrides the default visibility rules about how player perceives the target object /// If player is OBJECT_INVALID, the global visibility override will be set /// /// Player == VALID -> override: /// NWNX_VISIBILITY_DEFAULT = Remove the player override /// NWNX_VISIBILITY_VISIBLE = Target is always visible for player /// NWNX_VISIBILITY_HIDDEN = Target is always hidden for player /// /// Player == OBJECT_INVALID -> override: /// NWNX_VISIBILITY_DEFAULT = Remove the global override /// NWNX_VISIBILITY_VISIBLE = Target is globally visible /// NWNX_VISIBILITY_HIDDEN = Target is globally hidden /// NWNX_VISIBILITY_DM_ONLY = Target is only visible to DMs /// /// 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 /// </summary> /// <param name="player"></param> /// <param name="target"></param> /// <param name="override"></param> public static void SetVisibilityOverride(NWGameObject player, NWGameObject target, VisibilityType @override) { string sFunc = "SetVisibilityOverride"; NWNXCore.NWNX_PushArgumentInt(NWNX_Visibility, sFunc, (int)@override); NWNXCore.NWNX_PushArgumentObject(NWNX_Visibility, sFunc, target); NWNXCore.NWNX_PushArgumentObject(NWNX_Visibility, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Visibility, sFunc); }
/// <summary> /// Sets whether the player should always walk when given movement commands. /// If true, clicking on the ground or using WASD will trigger walking instead of running. /// </summary> /// <param name="player"></param> /// <param name="bWalk"></param> public static void SetAlwaysWalk(NWGameObject player, int bWalk) { string sFunc = "SetAlwaysWalk"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, bWalk); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
// Set oItem's additional value in gold pieces (Total cost = base_value + // additional_value). Will persist through saving. public static void SetAddGoldPieceValue(NWGameObject oItem, int g) { string sFunc = "SetAddGoldPieceValue"; NWNXCore.NWNX_PushArgumentInt(NWNX_Item, sFunc, g); NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); }
/// <summary> /// Starts the background music for the given player only /// </summary> /// <param name="player"></param> public static void MusicBackgroundStart(NWGameObject player) { string sFunc = "PlayBackgroundMusic"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, 1); // bool play = TRUE NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
// Set oItem's base item type. This will not be visible until the // item is refreshed (e.g. drop and take the item, or logging out // and back in). public static void SetBaseItemType(NWGameObject oItem, int nBaseItem) { string sFunc = "SetBaseItemType"; NWNXCore.NWNX_PushArgumentInt(NWNX_Item, sFunc, nBaseItem); NWNXCore.NWNX_PushArgumentObject(NWNX_Item, sFunc, oItem); NWNXCore.NWNX_CallFunction(NWNX_Item, sFunc); }
/// <summary> /// Changes the battle music track for the given player only /// </summary> /// <param name="player"></param> /// <param name="track"></param> public static void MusicBattleChange(NWGameObject player, int track) { string sFunc = "ChangeBattleMusic"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, track); NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }
// Sends a chat message. Channel is a NWNX_* constant. // If no target is provided, then it broadcasts to all eligible targets. // Returns TRUE if successful, FALSE otherwise. public static int SendMessage(int channel, string message, NWGameObject sender, NWGameObject target) { NWNXCore.NWNX_PushArgumentObject("NWNX_Chat", "SEND_MESSAGE", target); NWNXCore.NWNX_PushArgumentObject("NWNX_Chat", "SEND_MESSAGE", sender); NWNXCore.NWNX_PushArgumentString("NWNX_Chat", "SEND_MESSAGE", message); NWNXCore.NWNX_PushArgumentInt("NWNX_Chat", "SEND_MESSAGE", channel); NWNXCore.NWNX_CallFunction("NWNX_Chat", "SEND_MESSAGE"); return(NWNXCore.NWNX_GetReturnValueInt("NWNX_Chat", "SEND_MESSAGE")); }
/// <summary> /// Stops the background music for the given player only /// </summary> /// <param name="player"></param> public static void MusicBattleStop(NWGameObject player) { string sFunc = "PlayBattleMusic"; NWNXCore.NWNX_PushArgumentInt(NWNX_Player, sFunc, 0); // bool play = FALSE NWNXCore.NWNX_PushArgumentObject(NWNX_Player, sFunc, player); NWNXCore.NWNX_CallFunction(NWNX_Player, sFunc); }