public static void StartFurnitureConversation() { var player = OBJECT_SELF; var area = GetArea(player); var item = StringToObject(Events.GetEventData("ITEM_OBJECT_ID")); if (!Housing.CanPlaceFurniture(player, item)) { return; } Events.SkipEvent(); var furnitureTypeId = (int)Housing.GetFurnitureTypeFromItem(item); var targetLocation = Location(area, Vector( (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_X")), (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Y")), (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Z"))), 0.0f); SetLocalInt(player, "TEMP_FURNITURE_TYPE_ID", furnitureTypeId); SetLocalObject(player, "TEMP_FURNITURE_OBJECT", item); SetLocalLocation(player, "TEMP_FURNITURE_LOCATION", targetLocation); Dialog.StartConversation(player, player, nameof(PlayerHouseFurnitureDialog)); }
public static void OpenHomePurchaseMenu() { var player = GetLastUsedBy(); Creature.AddFeatByLevel(player, Feat.PropertyTool, 1); Dialog.StartConversation(player, OBJECT_SELF, nameof(PlayerHouseDialog)); }
/// <summary> /// Opens the recipe menu so that a player can select a different recipe to create. /// </summary> /// <param name="player">The player object</param> private static void SelectRecipe(uint player) { var device = OBJECT_SELF; var state = Craft.GetPlayerCraftingState(player); state.IsOpeningMenu = true; Dialog.StartConversation(player, device, nameof(RecipeDialog)); }
public static void UseOpenRestMenuFeat() { var feat = (Feat)Convert.ToInt32(Events.GetEventData("FEAT_ID")); if (feat != Feat.OpenRestMenu) { return; } Dialog.StartConversation(OBJECT_SELF, OBJECT_SELF, "RestMenuDialog"); }
public static void OpenDevice() { var player = GetLastOpenedBy(); if (!GetIsPC(player) || GetIsDM(player)) { return; } var state = Craft.GetPlayerCraftingState(player); var device = OBJECT_SELF; state.IsOpeningMenu = false; // A recipe isn't selected. Open the menu to pick. if (state.SelectedRecipe == RecipeType.Invalid) { var skillType = (SkillType)GetLocalInt(OBJECT_SELF, "CRAFTING_SKILL_TYPE_ID"); state.DeviceSkillType = skillType; state.IsOpeningMenu = true; Dialog.StartConversation(player, OBJECT_SELF, nameof(RecipeDialog)); } // Recipe has been picked. Spawn the command items into this device's inventory. else { var recipe = Craft.GetRecipe(state.SelectedRecipe); uint command; // Auto-Craft command: Only available if perk has been purchased. // todo: Need to write the mini-game. For now, only auto-craft will be available. //if (Perk.GetEffectivePerkLevel(player, _autoCraftPerk[state.DeviceSkillType]) > 0) { command = CreateItemOnObject(AutoCraftItemResref, device); SetName(command, $"Auto Craft: {recipe.Quantity}x {recipe.Name}"); } // Craft command // todo: Need to write the mini-game. For now, only auto-craft will be available. //command = CreateItemOnObject(CraftItemResref, device); //SetName(command, $"Craft: {recipe.Quantity}x {recipe.Name}"); // Load Components command command = CreateItemOnObject(LoadComponentsResref, device); SetName(command, "Load Components"); // Select Recipe command command = CreateItemOnObject(SelectRecipeResref, device); SetName(command, "Select Recipe"); } }
public static void PropertyTool() { var feat = (Feat)Convert.ToInt32(Events.GetEventData("FEAT_ID")); if (feat != Feat.PropertyTool) { return; } var player = OBJECT_SELF; var playerId = GetObjectUUID(player); var area = GetArea(player); var ownerPlayerUUID = GetLocalString(area, "HOUSING_OWNER_PLAYER_UUID"); // Not in a property. if (string.IsNullOrWhiteSpace(ownerPlayerUUID)) { SendMessageToPC(player, "The property tool may only be used when you are inside a player-owned property."); return; } // Check if the player has any menu-based permissions. var dbHouse = DB.Get <PlayerHouse>(ownerPlayerUUID); var permission = dbHouse.PlayerPermissions.ContainsKey(playerId) ? dbHouse.PlayerPermissions[playerId] : new PlayerHousePermission(); if (!permission.CanPlaceFurniture && !permission.CanAdjustPermissions) { SendMessageToPC(player, "You do not have permission to access this property's options."); return; } // We have access. Set the target object and location, which will be picked up by the menu. var target = StringToObject(Events.GetEventData("TARGET_OBJECT_ID")); var targetPositionX = (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_X")); var targetPositionY = (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Y")); var targetPositionZ = (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Z")); var location = Location(area, Vector(targetPositionX, targetPositionY, targetPositionZ), 0.0f); SetLocalObject(player, "TEMP_PROPERTY_TOOL_OBJECT", target); SetLocalLocation(player, "TEMP_PROPERTY_TOOL_LOCATION", location); // Open the menu. Dialog.StartConversation(player, player, nameof(PlayerHousePropertyDialog)); }
public static void UsePerkRefundTome() { var player = OBJECT_SELF; if (!GetIsPC(player) || GetIsDM(player)) { return; } var item = StringToObject(Events.GetEventData("ITEM_OBJECT_ID")); if (GetResRef(item) != "refund_tome") { return; } SetLocalObject(player, "PERK_REFUND_OBJECT", item); AssignCommand(player, () => ClearAllActions()); Dialog.StartConversation(player, player, nameof(PerkRefundDialog)); // Don't display the "You cannot use this item" message. Skip the event. Events.SetEventResult("1"); Events.SkipEvent(); }
/// <summary> /// Builds all chat commands and puts them into cache. /// </summary> private static void LoadChatCommands() { ChatCommands["bored"] = new ChatCommandDefinition( "Plays a bored animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetPauseBored)); }, (user, args) => string.Empty, false); ChatCommands["bow"] = new ChatCommandDefinition( "Plays a bow animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetBow)); }, (user, args) => string.Empty, false); ChatCommands["bug"] = new BugReportChatCommandDefinition(); ChatCommands["cdkey"] = new ChatCommandDefinition( "Displays your public CD key.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { string cdKey = GetPCPublicCDKey(user); SendMessageToPC(user, "Your public CD Key is: " + cdKey); }, (user, args) => string.Empty, false); ChatCommands["coord"] = new ChatCommandDefinition( "Displays your current coordinates in the area.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { Vector3 position = GetPosition(user); int cellX = (int)(position.X / 10); int cellY = (int)(position.Y / 10); SendMessageToPC(user, $"Current Area Coordinates: ({cellX}, {cellY})"); }, (user, args) => string.Empty, false); ChatCommands["copyitem"] = new ChatCommandDefinition( "Copies the targeted item.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { if (GetObjectType(target) != ObjectType.Item) { SendMessageToPC(user, "You can only copy items with this command."); return; } CopyItem(target, user, true); SendMessageToPC(user, "Item copied successfully."); }, (user, args) => string.Empty, true); ChatCommands["day"] = new ChatCommandDefinition( "Sets the world time to 8 AM.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { SetTime(8, 0, 0, 0); }, (user, args) => string.Empty, false); ChatCommands["deadback"] = new ChatCommandDefinition( "Plays a dead back animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingDeadBack, args); }, (user, args) => string.Empty, false); ChatCommands["deadfront"] = new ChatCommandDefinition( "Plays a dead front animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingDeadFront, args); }, (user, args) => string.Empty, false); ChatCommands["delete"] = new CharacterDeletionChatCommandDefinition(); ChatCommands["dice"] = new DiceChatCommandDefinition(); ChatCommands["drink"] = new ChatCommandDefinition( "Plays a drinking animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetDrink)); }, (user, args) => string.Empty, false); ChatCommands["drunk"] = new ChatCommandDefinition( "Plays a drunk animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingPauseDrunk, args); }, (user, args) => string.Empty, false); ChatCommands["duck"] = new ChatCommandDefinition( "Plays a duck animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetDodgeDuck)); }, (user, args) => string.Empty, false); ChatCommands["getlocalfloat"] = new GetLocalFloatChatCommandDefinition(); ChatCommands["getlocalint"] = new GetLocalIntChatCommandDefinition(); ChatCommands["getlocalstring"] = new GetLocalStringChatCommandDefinition(); ChatCommands["getplot"] = new ChatCommandDefinition( "Gets whether an object is marked plot.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { if (GetPlotFlag(target)) { SendMessageToPC(user, "Target is marked plot."); } else { SendMessageToPC(user, "Target is NOT marked plot."); } }, (user, args) => string.Empty, true); ChatCommands["greet"] = new ChatCommandDefinition( "Plays a greet animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetGreeting)); }, (user, args) => string.Empty, false); ChatCommands["help"] = new ChatCommandDefinition( "Displays all chat commands available to you.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { var authorization = Authorization.GetAuthorizationLevel(user); if (authorization == AuthorizationLevel.DM) { SendMessageToPC(user, HelpTextDM); } else if (authorization == AuthorizationLevel.Admin) { SendMessageToPC(user, HelpTextAdmin); } else { SendMessageToPC(user, HelpTextPlayer); } }, (user, args) => string.Empty, false); ChatCommands["interact"] = new ChatCommandDefinition( "Plays an interact animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.LoopingGetMid)); }, (user, args) => string.Empty, false); ChatCommands["kill"] = new ChatCommandDefinition( "Kills your target.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { var amount = GetMaxHitPoints(target) + 11; var damage = EffectDamage(amount); ApplyEffectToObject(DurationType.Instant, damage, target); }, (user, args) => string.Empty, false); ChatCommands["laughing"] = new ChatCommandDefinition( "Plays a laughing animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingTalkLaughing, args); }, (user, args) => string.Empty, false); ChatCommands["listen"] = new ChatCommandDefinition( "Plays a listen animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingListen, args); }, (user, args) => string.Empty, false); ChatCommands["look"] = new ChatCommandDefinition( "Plays a look far animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingLookFar, args); }, (user, args) => string.Empty, false); ChatCommands["name"] = new ChatCommandDefinition( "Plays a drunk animation.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { if (GetIsPC(target) || GetIsDM(target)) { SendMessageToPC(user, "PCs cannot be targeted with this command."); return; } string name = string.Empty; foreach (var arg in args) { name += " " + arg; } SetName(target, name); }, (user, args) => { if (args.Length <= 0) { return("Please enter a name. Example: /name My Creature"); } return(string.Empty); }, false); ChatCommands["night"] = new ChatCommandDefinition( "Sets the world time to 8 AM.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { SetTime(20, 0, 0, 0); }, (user, args) => string.Empty, false); ChatCommands["pickup"] = new ChatCommandDefinition( "Plays an interact animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.LoopingGetLow)); }, (user, args) => string.Empty, false); ChatCommands["pos"] = new ChatCommandDefinition( "Displays your current position in the area.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { var position = GetPosition(user); SendMessageToPC(user, $"Current Position: ({position.X}, {position.Y}, {position.Z})"); }, (user, args) => string.Empty, false); ChatCommands["read"] = new ChatCommandDefinition( "Plays a read animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetRead)); }, (user, args) => string.Empty, false); ChatCommands["rest"] = new ChatCommandDefinition( "Opens the rest menu.", CommandPermissionType.Player, (user, target, location, args) => { Dialog.StartConversation(user, user, nameof(RestMenu)); }, (user, args) => string.Empty, false); ChatCommands["rez"] = new ChatCommandDefinition( "Revives you, heals you to full, and restores all MP.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { if (GetIsDead(user)) { ApplyEffectToObject(DurationType.Instant, EffectResurrection(), user); } ApplyEffectToObject(DurationType.Instant, EffectHeal(999), user); }, (user, args) => string.Empty, false); ChatCommands["salute"] = new ChatCommandDefinition( "Plays a salute animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetSalute)); }, (user, args) => string.Empty, false); ChatCommands["save"] = new ChatCommandDefinition( "Manually saves your character. Your character also saves automatically every few minutes.", CommandPermissionType.Player, (user, target, location, args) => { ExportSingleCharacter(user); SendMessageToPC(user, "Character saved successfully."); }, (user, args) => string.Empty, false); ChatCommands["scratchhead"] = new ChatCommandDefinition( "Plays a scratch head animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetPauseScratchHead)); }, (user, args) => string.Empty, false); ChatCommands["setlocalfloat"] = new SetLocalFloatChatCommandDefinition(); ChatCommands["setlocalint"] = new SetLocalIntChatCommandDefinition(); ChatCommands["setlocalstring"] = new SetLocalStringChatCommandDefinition(); ChatCommands["setportrait"] = new SetPortraitChatCommandDefinition(); ChatCommands["sidestep"] = new ChatCommandDefinition( "Plays a side-step animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetDodgeSide)); }, (user, args) => string.Empty, false); ChatCommands["sit"] = new ChatCommandDefinition( "Makes your character sit down.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingSitCross, args); }, (user, args) => string.Empty, false); ChatCommands["spasm"] = new ChatCommandDefinition( "Plays a spasm animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetSpasm)); }, (user, args) => string.Empty, false); ChatCommands["spawngold"] = new ChatCommandDefinition( "Spawns gold of a specific quantity on your character. Example: /spawngold 33", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { int quantity = 1; if (args.Length >= 1) { if (!int.TryParse(args[0], out quantity)) { return; } } GiveGoldToCreature(user, quantity); }, (user, args) => { if (args.Length <= 0) { return(ColorToken.Red("Please specify a quantity. Example: /spawngold 34")); } return(string.Empty); }, false); ChatCommands["spawnitem"] = new SpawnItemChatCommandDefinition(); ChatCommands["taunt"] = new ChatCommandDefinition( "Plays a taunt animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetTaunt)); }, (user, args) => string.Empty, false); ChatCommands["time"] = new ChatCommandDefinition( "Returns the current UTC server time.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { DateTime now = DateTime.UtcNow; string nowText = now.ToString("yyyy-MM-dd hh:mm:ss"); SendMessageToPC(user, "Current Server Date: " + nowText); }, (user, args) => string.Empty, false); ChatCommands["tired"] = new ChatCommandDefinition( "Plays a taunt animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { LoopingAnimationAction(user, Animation.LoopingPauseTired, args); }, (user, args) => string.Empty, false); ChatCommands["tpwp"] = new ChatCommandDefinition( "Teleports you to a waypoint with a specified tag.", CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { string tag = args[0]; uint wp = GetWaypointByTag(tag); if (!GetIsObjectValid(wp)) { SendMessageToPC(user, "Invalid waypoint tag. Did you enter the right tag?"); return; } AssignCommand(user, () => ActionJumpToLocation(GetLocation(wp))); }, (user, args) => { if (args.Length < 1) { return("You must specify a waypoint tag. Example: /tpwp MY_WAYPOINT_TAG"); } return(string.Empty); }, false); ChatCommands["victory1"] = new ChatCommandDefinition( "Plays a victory 1 animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetVictory1)); }, (user, args) => string.Empty, false); ChatCommands["victory2"] = new ChatCommandDefinition( "Plays a victory 2 animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetVictory2)); }, (user, args) => string.Empty, false); ChatCommands["victory3"] = new ChatCommandDefinition( "Plays a victory 3 animation.", CommandPermissionType.Player | CommandPermissionType.DM | CommandPermissionType.Admin, (user, target, location, args) => { AssignCommand(user, () => ActionPlayAnimation(Animation.FireForgetVictory3)); }, (user, args) => string.Empty, false); }