public async Task ForceWork(int amount = 1, bool isNpcs = true) { Context.AdminCheck(); Player player = Context.GetPlayer(Player.IgnoreException.All); Area area = player.Area; var popu = area.GetPopulation(isNpcs ? Neitsillia.Areas.AreaExtentions.Population.Type.Population : Neitsillia.Areas.AreaExtentions.Population.Type.Bounties); if (popu == null || popu.Count == 0) { await ReplyAsync("No population here"); return; } for (int i = 0; i < amount && popu.Count > 0; i++) { NPC n = popu.Random(); PopulationHandler.Add(area, n); await ReplyAsync($"Sent {n} to work"); await Task.Delay(1000); } }
internal Area Remove(int i, Area area) { if (i < 0 || i > NPCMembers.Count) { return(area); } NPC npc = NPCMembers[i]; if (npc.IsPet()) { string[] data = npc.origin.Split('\\'); if (data.Length > 1) { string id = $"{data[0]}\\{data[1]}"; PetList pl = PetList.Load(id); if (pl != null && pl._id == id) { _ = pl.UpdatePet(npc); } else { Orphanage.AddPet(npc); } } else { Orphanage.AddPet(npc); } } else { if (area != null) { PopulationHandler.Add(area, npc); } else { npc.Respawn(); } } NPCMembers.RemoveAt(i); return(area); }
public async Task New_Bounty(string areaName, string creatureName = null, int floor = 0, int level = 1, string grantDrop = null) { if (IsGMLevel(4).Result) { areaName = StringM.UpperAt(areaName); //areaName = Area.AreaDataExist(areaName); if (areaName != null) { Area area = Area.LoadFromName(areaName); floor = Verify.MinMax(floor, area.floors); // NPC mob = null; if (creatureName != null) { mob = NPC.GenerateNPC(Verify.Min(level, 0), StringM.UpperAt(creatureName)); } if (mob == null) { mob = area.GetAMob(Program.rng, floor); } // if (grantDrop != null) { Item grant = Item.LoadItem(grantDrop); if (grant != null) { mob.AddItemToInv(grant, 1, true); } } // PopulationHandler.Add(area, mob); await DUtils.DeleteContextMessageAsync(Context); } else { await DUtils.Replydb(Context, "Area not found."); } } }
private async Task <MsgType> HandleAllPlayersDead(EmbedBuilder result) { NPC mob = (NPC)Utils.RandomElement(mobParty).character; string lostInfo = allMobsDead ? "No one is left standing to claim victory." : "You have been defeated." + Environment.NewLine; if (currentArea.IsDungeon) { await Database.DeleteRecord <Area>("Dungeons", MainAreaPath.path, "AreaId"); } MsgType msgType = MsgType.Main; Encounter encounter = await ChallengeEnd(); if (encounter != null) { msgType = encounter.Name switch { Encounter.Names.Loot => MsgType.Loot, _ => msgType, }; } bool deathCost = msgType == MsgType.Main; foreach (var cb in playerParty) { PerkLoad.CheckPerks(cb.character, Perk.Trigger.EndFight, cb.character); if (encounter != null) { if (encounter.koinsToGain > 0) { cb.character.KCoins += encounter.koinsToGain; } if (encounter.xpToGain > 0) { cb.character.XpGain(encounter.xpToGain, 1); } } if (cb.character is Player player) { if (!allMobsDead && deathCost) { lostInfo += DefeatCost(player, mob, 0.5) + Environment.NewLine; } await player.Respawn(false); if (endDungeon) { player.AreaInfo = ParentAreaPath(currentArea, partyLeader.AreaInfo.floor); } player.SaveFileMongo(); } else if (cb.character is NPC n) { FollowerCheck(n, party, allPlayersDead); } } result.AddField("Defeat", lostInfo); if (encounter != null) { string loot = null; if (encounter.loot != null && encounter.loot.Count > 0) { int c = Math.Min(encounter.loot.Count, 10); for (int i = 0; i < c; i++) { loot += $"{i + 1}|" + encounter.loot[i] + Environment.NewLine; } if (c < encounter.loot.Count) { loot += $"And {encounter.loot.Count - c} more..."; } } string extraResult = (encounter.koinsToGain > 0 ? $"+{encounter.koinsToGain} Kuts" + Environment.NewLine : null) + (encounter.xpToGain > 0 ? $"+{encounter.xpToGain} XP" + Environment.NewLine : null) + loot; result.AddField("Rewards", extraResult.Length != 0 ? extraResult : "None"); encounter.koinsToGain = 0; encounter.xpToGain = 0; if (party != null) { partyLeader.NewEncounter(encounter); } } if (!allMobsDead && currentEncounter.Name != Encounter.Names.Bounty && currentArea.type != AreaType.Dungeon && currentArea.type != AreaType.Arena) { PopulationHandler.Add(currentArea, mob); } return(msgType); }
public async Task New_NPC(string areaName, int amount = 1, string profession = "Child", int level = 0) { if (IsGMLevel(4).Result) { //areaName = Area.AreaDataExist(areaName); if (areaName != null) { NPC[] npcs = new NPC[amount]; for (int i = 0; i < amount; i++) { npcs[i] = NPC.NewNPC(level, profession, null); } Area area = Area.LoadFromName(areaName); string populationId = area.GetPopulation(Neitsillia.Areas.AreaExtentions.Population.Type.Population)._id; EmbedBuilder noti = new EmbedBuilder(); noti.WithTitle($"{area.name} Population"); amount = 0; if (npcs != null && npcs.Length > 0) { foreach (NPC n in npcs) { if (n != null) { if (n.profession == Neitsillia.ReferenceData.Profession.Child) { if (area.parent == null) { n.origin = area.name; } else { n.origin = area.parent; } n.displayName = n.name + " Of " + n.origin; } else { n.displayName = n.name; } PopulationHandler.Add(populationId, n); amount++; } } } if (amount != 0) { await ReplyAsync("NPCs created"); } else { await ReplyAsync("No new NPC were created"); } } else { await DUtils.Replydb(Context, "Area not found."); } } }