public static int ModCallAddQuest(object[] args) { if (args.Length < 9) { SpiritMod.Instance.Logger.Warn("Error adding custom quest! Less than 9 arguments means something must be missing, check you've added everything you need to add!"); return(-1); } int index = 1; // quest name if (!QuestUtils.TryUnbox(args[index++], out string questName, "Quest name")) { return(-1); } // quest category if (!QuestUtils.TryUnbox(args[index++], out string questCategory, "Quest category")) { return(-1); } // TODO: check if quest category exists. if it doesn't, add it, make the colour white. // quest client if (!QuestUtils.TryUnbox(args[index++], out string questClient, "Quest client")) { return(-1); } // quest description if (!QuestUtils.TryUnbox(args[index++], out string questDesc, "Quest description")) { return(-1); } // quest rewards if (!QuestUtils.TryUnbox(args[index++], out (int, int)[] questRewards, "Quest rewards")) { return(-1); } // quest difficulty if (!QuestUtils.TryUnbox(args[index++], out int questDifficulty, "Quest difficulty")) { return(-1); } // quest image if (!QuestUtils.TryUnbox(args[index++], out Texture2D questImage, "Quest image")) { return(-1); } // quest objectives List <QuestTask> tasks = new List <QuestTask>(); for (int i = index; i < args.Length; i++) { if (!QuestUtils.TryUnbox(args[i], out object[] objectiveArgs, "Quest objective " + (i - index + 1)))
public string GetObjectives(bool showProgress) { StringBuilder builder = new StringBuilder(); if (_monsterNameOverride == null) { string count = _killsRequired > 1 ? _killsRequired.ToString() : (_Singular ? "" : "a"); builder.Append("Kill ").Append(count).Append(" "); } // start with: - Kill x monster, monster or monster if (_monsterNameOverride == null) { for (int i = 0; i < _monsterIDs.Length; i++) { string monsterName = Lang.GetNPCNameValue(_monsterIDs[i]); monsterName += QuestUtils.GetPluralEnding(_killsRequired, monsterName); if (_monsterIDs.Length == 1) { // if there's multiple monsters, add a character to show plurality builder.Append(monsterName); break; } else { builder.Append(monsterName); if (i < _monsterIDs.Length - 2) { builder.Append(", "); } else if (i == _monsterIDs.Length - 2) { builder.Append(" or "); } } } } else { builder.Append(_monsterNameOverride); } // add a progress bracket at the end like: (x/y) if (showProgress) { builder.Append(" [c/97E2E2:(").Append(_killCount).Append("/").Append(_killsRequired).Append(")]"); } return(builder.ToString()); }
public override QuestTask Parse(object[] args) { //NPC type if (!QuestUtils.TryUnbox(args[1], out int npcID)) { if (QuestUtils.TryUnbox(args[1], out short IDasShort, "NPC Type")) { npcID = IDasShort; } else { return(null); } }
public override QuestTask Parse(object[] args) { // get the item ID int itemID = -1; if (!QuestUtils.TryUnbox(args[1], out itemID)) { if (QuestUtils.TryUnbox(args[1], out short IDasShort, "Item ID")) { itemID = IDasShort; } else { return(null); } }
public override QuestTask Parse(object[] args) { // get the ids int[] monsterIDs; if (!QuestUtils.TryUnbox(args[1], out monsterIDs)) { if (QuestUtils.TryUnbox(args[1], out int id)) { monsterIDs = new int[] { id } } ; else if (QuestUtils.TryUnbox(args[1], out short idShort)) { monsterIDs = new int[] { idShort } } ; else { return(null); } } if (monsterIDs == null || monsterIDs.Length == 0) { return(null); } // get the amount of kills required if (!QuestUtils.TryUnbox(args[2], out int amount, "Kills required")) { return(null); } // get the name override, if there is one string nameOverride = null; if (args.Length > 3) { if (!QuestUtils.TryUnbox(args[3], out nameOverride, "Slay Task name override")) { return(null); } } return(new SlayTask(monsterIDs, amount, nameOverride)); }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (IsMouseHovering || IsSelected) { if (DrawFilled) { spriteBatch.Draw(Main.blackTileTexture, GetDimensions().ToRectangle(), IsSelected ? SelectedFillColour : HoverFillColour); } if (DrawBorder) { QuestUtils.DrawRectangleBorder(spriteBatch, GetDimensions().ToRectangle(), IsSelected ? SelectedOutlineColour : HoverOutlineColour); } } else if (DrawBorder) { QuestUtils.DrawRectangleBorder(spriteBatch, GetDimensions().ToRectangle(), NormalOutlineColour); } }
public void Draw(SpriteBatch spriteBatch, ref float y) { var builder = new StringBuilder(); Color c = QuestManager.GetCategoryInfo(Quest.QuestCategory).Color; string hex = $"{c.R:X2}{c.G:X2}{c.B:X2}"; builder.Append("[c/").Append(hex).Append(":").Append(Quest.QuestName).AppendLine("]"); if (Quest.IsActive) { string currentObjectives = Quest.GetObjectivesHUD(); builder.Append(currentObjectives); _prevText = builder.ToString(); } TextSnippet[] allSnippets = ChatManager.ParseMessage(_prevText, Color.White * _opacity).ToArray(); ChatManager.ConvertNormalSnippets(allSnippets); string text = QuestUtils.WrapText(Main.fontMouseText, allSnippets, _prevText, 260f, 0.8f); string[] lines = text.Split('\n'); float x = Main.screenWidth - (Main.playerInventory ? 450 : 298); float lineHeight = Main.fontMouseText.MeasureString(" ").Y * 0.8f - 1f; foreach (string line in lines) { TextSnippet[] snips = ChatManager.ParseMessage(line, Color.White * _opacity).ToArray(); ChatManager.ConvertNormalSnippets(snips); for (int i = 0; i < snips.Length; i++) { snips[i].Color *= _opacity; } ChatManager.DrawColorCodedStringShadow(spriteBatch, Main.fontMouseText, snips, new Vector2(x, y), Color.Black * _opacity, 0f, Vector2.Zero, new Vector2(0.8f)); ChatManager.DrawColorCodedString(spriteBatch, Main.fontMouseText, snips, new Vector2(x, y), Color.White, 0f, Vector2.Zero, new Vector2(0.8f), out int h, -1f); y += lineHeight; } }
public override QuestTask Parse(object[] args) { // get the func if (!QuestUtils.TryUnbox(args[1], out Func <Player, bool> func, "Explore function")) { return(null); } // get the distance if (!QuestUtils.TryUnbox(args[2], out float distance, "Distance")) { return(null); } // get the area's name if (!QuestUtils.TryUnbox(args[3], out string name, "Area name")) { return(null); } return(new ExploreTask(func, distance, name)); }
public override QuestTask Parse(object[] args) { if (!QuestUtils.TryUnbox(args[1], out object[] tasks, "Concurrent Task's Tasks"))