public override void AI(NPC npc) { var mymod = (TheLunaticMod)this.mod; if (!mymod.Config.Enabled) { return; } if (Main.rand == null) { return; } var myworld = ModContent.GetInstance <TheLunaticWorld>(); if (myworld == null) { return; } // Kill town NPCs above ground every minute when set to do so if (myworld.GameLogic.KillSurfaceTownNPCs) { if (npc.townNPC && npc.position.Y < (Main.worldSurface * 16.0) && Main.rand.Next(60 * 60) == 0) { NPCHelpers.Kill(npc); return; } } }
private async Task <bool> GambleItems(Client client, MovementMode movementMode) { bool shouldGamble = client.Game.Me.Attributes[D2NG.Core.D2GS.Players.Attribute.GoldInStash] > 7_000_000; if (shouldGamble && System.Threading.Interlocked.Exchange(ref isAnyClientGambling, 1) == 0) { var gambleNPC = NPCHelpers.GetGambleNPC(client.Game.Act); Log.Information($"Gambling items at {gambleNPC}"); var pathToGamble = await _pathingService.GetPathToNPC(client.Game, gambleNPC, movementMode); if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToGamble, movementMode)) { Log.Warning($"{movementMode} to {gambleNPC} failed at {client.Game.Me.Location}"); return(false); } var uniqueNPC = NPCHelpers.GetUniqueNPC(client.Game, gambleNPC); if (uniqueNPC == null) { Log.Warning($"{gambleNPC} not found at {client.Game.Me.Location}"); return(false); } NPCHelpers.GambleItems(client.Game, uniqueNPC); System.Threading.Interlocked.Exchange(ref isAnyClientGambling, 0); } return(true); }
private async Task <bool> RepairItems(Game game, MovementMode movementMode) { if (NPCHelpers.ShouldGoToRepairNPC(game)) { var repairNPC = NPCHelpers.GetRepairNPC(game.Act); Log.Information($"Client {game.Me.Name} moving to {repairNPC} for repair/arrows"); var pathRepairNPC = repairNPC == NPCCode.Hratli ? await _pathingService.GetPathToObject(game, EntityCode.Hratli, movementMode) : await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, repairNPC, movementMode); if (pathRepairNPC.Count > 0 && await MovementHelpers.TakePathOfLocations(game, pathRepairNPC, movementMode)) { var uniqueNPC = NPCHelpers.GetUniqueNPC(game, repairNPC); if (uniqueNPC == null) { Log.Warning($"Client {game.Me.Name} Did not find {repairNPC} at {game.Me.Location}"); return(false); } if (!NPCHelpers.RepairItemsAndBuyArrows(game, uniqueNPC)) { Log.Warning($"Client {game.Me.Name} Selling items and refreshing potions to {repairNPC} failed at {game.Me.Location}"); } } else { Log.Warning($"Client {game.Me.Name} {movementMode} to {repairNPC} failed at {game.Me.Location}"); } } return(true); }
private async Task <bool> RefreshAndSellItems(Game game, MovementMode movementMode, TownManagementOptions options) { var sellItemCount = game.Inventory.Items.Count(i => !Pickit.Pickit.ShouldKeepItem(game, i)) + game.Cube.Items.Count(i => !Pickit.Pickit.ShouldKeepItem(game, i)); if (NPCHelpers.ShouldRefreshCharacterAtNPC(game) || sellItemCount > 5 || options.ItemsToBuy?.Count > 0) { var sellNpc = NPCHelpers.GetSellNPC(game.Act); Log.Information($"Client {game.Me.Name} moving to {sellNpc} for refresh and selling {sellItemCount} items"); var pathSellNPC = await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, sellNpc, movementMode); if (pathSellNPC.Count > 0 && await MovementHelpers.TakePathOfLocations(game, pathSellNPC, movementMode)) { var uniqueNPC = NPCHelpers.GetUniqueNPC(game, sellNpc); if (uniqueNPC == null) { Log.Warning($"Client {game.Me.Name} Did not find {sellNpc} at {game.Me.Location}"); return(false); } if (!NPCHelpers.SellItemsAndRefreshPotionsAtNPC(game, uniqueNPC, options.ItemsToBuy)) { Log.Warning($"Client {game.Me.Name} Selling items and refreshing potions failed at {game.Me.Location}"); return(false); } } else { Log.Warning($"Client {game.Me.Name} {movementMode} to {sellNpc} failed at {game.Me.Location}"); return(false); } } return(true); }
private async Task <bool> IdentifyItems(Game game, MovementMode movementMode) { var unidentifiedItemCount = game.Inventory.Items.Count(i => !i.IsIdentified) + game.Cube.Items.Count(i => !i.IsIdentified); if (unidentifiedItemCount > 6) { Log.Information($"Visiting Deckard Cain with {unidentifiedItemCount} unidentified items"); var deckhardCainCode = NPCHelpers.GetDeckardCainForAct(game.Act); var deckardCain = NPCHelpers.GetUniqueNPC(game, deckhardCainCode); var pathDeckardCain = new List <Point>(); if (deckardCain != null) { pathDeckardCain = await _pathingService.GetPathToLocation(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, deckardCain.Location, movementMode); } else { pathDeckardCain = await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, deckhardCainCode, movementMode); } if (!await MovementHelpers.TakePathOfLocations(game, pathDeckardCain, movementMode)) { Log.Warning($"Client {game.Me.Name} {movementMode} to deckard cain failed at {game.Me.Location}"); return(false); } return(NPCHelpers.IdentifyItemsAtDeckardCain(game)); } return(true); }
protected override void OnClaimNPCForMobs(NPC npc) { if (SkeletonRaidersAmbush.AllSkeletons.Contains(npc.type)) { if (!this.ValidateRaider(npc)) { NPCHelpers.Remove(npc); } else { base.OnClaimNPCForMobs(npc); } } }
public override bool CheckActive() { float dist; int playerIdx = this.npc.FindClosestPlayer(out dist); if (dist >= 1300) // 81.25 tiles away { NPCHelpers.Remove(npc); return(false); } else { Timers.SetTimer("IntrinsicsGhostExists", 2, false, () => false); } return(base.CheckActive()); }
/// <summary> /// Gets a list of assorted game data statistics, formatted for (markdown) output. /// </summary> /// <param name="mods">Mods to display in this list. Typically only the set of loaded mods (ModLoader.Mods`).</param> /// <returns></returns> public static IList <string> GetFormattedGameInfo(IEnumerable <Mod> mods) { var list = new List <string>(); var modsList = mods.OrderBy(m => m.Name) .SafeSelect(m => StringFormattingHelpers.SanitizeMarkdown(m.DisplayName) + " " + m.Version.ToString()) .ToArray(); bool isDay = Main.dayTime; double timeOfDay = Main.time; int halfDays = WorldStateHelpers.GetElapsedHalfDays(); string worldSize = WorldHelpers.GetSize().ToString(); string[] worldProg = GameInfoHelpers.GetVanillaProgressList().ToArray(); int activeItems = ItemHelpers.GetActive().Count; int activeNpcs = NPCHelpers.GetActive().Count; //string[] playerInfos = InfoHelpers.GetCurrentPlayerInfo().ToArray(); //string[] playerEquips = InfoHelpers.GetCurrentPlayerEquipment().ToArray(); int activePlayers = Main.ActivePlayersCount; string netmode = Main.netMode == 0 ? "single-player" : "multiplayer"; bool autopause = Main.autoPause; bool autosave = Main.autoSave; int lighting = Lighting.lightMode; int lightingThreads = Lighting.LightingThreads; int frameSkipMode = Main.FrameSkipMode; bool isMaximized = Main.screenMaximized; int windowWid = Main.screenWidth; int windowHei = Main.screenHeight; int qualityStyle = Main.qaStyle; bool bgOn = Main.BackgroundEnabled; bool childSafe = !ChildSafety.Disabled; float gameZoom = Main.GameZoomTarget; float uiZoom = Main.UIScale; list.Add("tModLoader version: " + ModLoader.version.ToString()); list.Add(FormattedGameInfoHelpers.RenderMarkdownModTable(modsList)); list.Add(FormattedGameInfoHelpers.RenderMarkdownPlayersTable()); for (int i = 0; i < Main.player.Length; i++) { Player plr = Main.player[i]; if (plr == null || !plr.active) { continue; } list.Add(FormattedGameInfoHelpers.RenderMarkdownPlayerEquipsTable(plr)); } list.Add("Is day: " + isDay + ", Time of day/night: " + timeOfDay + ", Elapsed half days: " + halfDays); //+ ", Total time (seconds): " + Main._drawInterfaceGameTime.TotalGameTime.Seconds; list.Add("World name: " + StringFormattingHelpers.SanitizeMarkdown(Main.worldName) + ", world size: " + worldSize); list.Add("World progress: " + (worldProg.Length > 0 ? string.Join(", ", worldProg) : "none")); list.Add("Items on ground: " + activeItems + ", Npcs active: " + activeNpcs); //list.Add( "Player info: " + string.Join( ", ", playerInfos ) ); //list.Add( "Player equips: " + (playerEquips.Length > 0 ? string.Join(", ", playerEquips) : "none" ) ); list.Add("Player count: " + activePlayers + " (" + netmode + ")"); list.Add("Autopause: " + autopause); list.Add("Autosave: " + autosave); list.Add("Lighting mode: " + lighting); list.Add("Lighting threads: " + lightingThreads); list.Add("Frame skip mode: " + frameSkipMode); list.Add("Is screen maximized: " + isMaximized); list.Add("Screen resolution: " + windowWid + " " + windowHei); list.Add("Quality style: " + qualityStyle); list.Add("Background on: " + bgOn); list.Add("Child safety: " + childSafe); list.Add("Game zoom: " + gameZoom); list.Add("UI zoom: " + uiZoom); list.Add("FrameworkVersion.Framework: " + Enum.GetName(typeof(FrameworkVersion), FrameworkVersion.Framework)); list.Add("FrameworkVersion.Version: " + FrameworkVersion.Version.ToString()); return(list); }