private static (IEnumerable <SkillViewModel> selectedSkills, SkillViewModel weakenSkill, SkillViewModel inanimateSkill) GetPsychopathSkills(Player bot) { var allMySkills = SkillProcedures.GetSkillViewModelsOwnedByPlayer(bot.Id).Where(s => s.StaticSkill.ExclusiveToFormSourceId == null && s.StaticSkill.ExclusiveToItemSourceId == null); var selectedSkills = new List <SkillViewModel>(); SkillViewModel weakenSkill = null; var inanimateSkill = allMySkills.FirstOrDefault(s => s.MobilityType == PvPStatics.MobilityInanimate || s.MobilityType == PvPStatics.MobilityPet); if (inanimateSkill != null) { selectedSkills.Add(inanimateSkill); } if (bot.FirstName.Contains("Evil ") || bot.FirstName.Contains("Ruthless ") || bot.FirstName.Contains("Eternal ")) { weakenSkill = allMySkills.FirstOrDefault(s => s.StaticSkill.Id == PvPStatics.Spell_WeakenId); if (weakenSkill != null) { selectedSkills.Add(weakenSkill); } } if (bot.FirstName.Contains("Eternal ")) { var animateSkill = allMySkills.FirstOrDefault(s => s.MobilityType == PvPStatics.MobilityFull); if (animateSkill != null) { selectedSkills.Add(animateSkill); } } return(selectedSkills, weakenSkill, inanimateSkill); }
private static void PerformAnimateTransformation(Player victim, Player attacker, DbStaticForm targetForm, LogBox output) { var playerRepo = new EFPlayerRepository(); var dbVictim = playerRepo.Players.FirstOrDefault(p => p.Id == victim.Id); SkillProcedures.UpdateFormSpecificSkillsToPlayer(dbVictim, targetForm.Id); DomainRegistry.Repository.Execute(new ChangeForm { PlayerId = dbVictim.Id, FormSourceId = targetForm.Id }); // wipe out half of the target's mana dbVictim.Mana -= dbVictim.MaxMana / 2; if (dbVictim.Mana < 0) { dbVictim.Mana = 0; } // Remove any Self Restore entires. RemoveSelfRestore(dbVictim); var targetbuffs = ItemProcedures.GetPlayerBuffs(dbVictim); dbVictim = PlayerProcedures.ReadjustMaxes(dbVictim, targetbuffs); // take away some of the victim's XP based on the their level // target.XP += -2.5M * target.Level; playerRepo.SavePlayer(dbVictim); output.LocationLog += $"<br><b>{dbVictim.GetFullName()} was completely transformed into a {targetForm.FriendlyName} here.</b>"; output.AttackerLog += $"<br><b>You fully transformed {dbVictim.GetFullName()} into a {targetForm.FriendlyName}</b>!"; output.VictimLog += $"<br><b>You have been fully transformed into a {targetForm.FriendlyName}!</b>"; // Let the target know they are best friends with the angel plush. if (attacker.BotId == AIStatics.MinibossPlushAngelId) { output.VictimLog += $"<br><br><b>{attacker.GetFullName()}</b> was happy to make you into a new friend!<br>"; } TFEnergyProcedures.DeleteAllPlayerTFEnergiesOfFormSourceId(dbVictim.Id, targetForm.Id); StatsProcedures.AddStat(dbVictim.MembershipId, StatsProcedures.Stat__TimesAnimateTFed, 1); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__TimesAnimateTFing, 1); }
public static IEnumerable <SkillViewModel> AvailableSkills(Player attacker, Player target, bool includeArchived) { IEnumerable <SkillViewModel> output = SkillProcedures.GetSkillViewModelsOwnedByPlayer(attacker.Id); if (!includeArchived) { output = output.Where(s => !s.dbSkill.IsArchived); } // filter out spells that you can't use on your target if (FriendProcedures.PlayerIsMyFriend(attacker, target) || target.BotId < AIStatics.ActivePlayerBotId) { // do nothing, all spells are okay } // both players are in protection; only allow animate spells else if (attacker.GameMode == (int)GameModeStatics.GameModes.Protection && target.GameMode == (int)GameModeStatics.GameModes.Protection) { output = output.Where(s => s.MobilityType == PvPStatics.MobilityFull); } // attack or the target is in superprotection and not a friend or bot; no spells work else if (target.GameMode == (int)GameModeStatics.GameModes.Superprotection || (attacker.GameMode == (int)GameModeStatics.GameModes.Superprotection && target.BotId == AIStatics.ActivePlayerBotId)) { output = output.Where(s => s.MobilityType == "NONEXISTANT"); } // either player invisible; no spells work else if (target.GameMode == (int)GameModeStatics.GameModes.Invisible || attacker.GameMode == (int)GameModeStatics.GameModes.Invisible) { output = output.Where(s => s.MobilityType == "NONEXISTENT"); } // filter out MC spells for bots if (target.BotId < AIStatics.ActivePlayerBotId) { output = output.Where(s => s.MobilityType != PvPStatics.MobilityMindControl); } // only show inanimates for rat thieves if (target.BotId == AIStatics.MaleRatBotId || target.BotId == AIStatics.FemaleRatBotId) { output = output.Where(s => s.MobilityType == PvPStatics.MobilityInanimate); } // only show Weaken for valentine if (target.BotId == AIStatics.ValentineBotId) { output = output.Where(s => s.dbSkill.SkillSourceId == PvPStatics.Spell_WeakenId); } // only bimbo spell works on nerd mouse boss if (target.BotId == AIStatics.MouseNerdBotId) { output = output.Where(s => s.StaticSkill.Id == BossProcedures_Sisters.BimboSpellSourceId); } // only nerd spell works on nerd bimbo boss if (target.BotId == AIStatics.MouseBimboBotId) { output = output.Where(s => s.StaticSkill.Id == BossProcedures_Sisters.NerdSpellSourceId); } // Vanquish and weaken only works against dungeon demons if (target.BotId == AIStatics.DemonBotId) { output = output.Where(s => s.StaticSkill.Id == PvPStatics.Dungeon_VanquishSpellSourceId || s.StaticSkill.Id == PvPStatics.Spell_WeakenId); } // Filter out Vanquish when attacking non-Dungeon Demon player if (target.BotId != AIStatics.DemonBotId) { output = output.Where(s => s.StaticSkill.Id != PvPStatics.Dungeon_VanquishSpellSourceId); } // Fae-In-A-Bottle only works against Narcissa if (target.BotId == AIStatics.FaebossBotId) { output = output.Where(s => s.StaticSkill.Id == BossProcedures_FaeBoss.SpellUsedAgainstNarcissaSourceId); } // Filter out Fae-In-A-Bottle when attacking non-Narcissa player if (target.BotId != AIStatics.FaebossBotId) { output = output.Where(s => s.StaticSkill.Id != BossProcedures_FaeBoss.SpellUsedAgainstNarcissaSourceId); } // only inanimate and animal spells work on minibosses, donna, and lovebringer if (AIStatics.IsAMiniboss(target.BotId) || target.BotId == AIStatics.MotorcycleGangLeaderBotId || target.BotId == AIStatics.BimboBossBotId) { output = output.Where(s => s.MobilityType == PvPStatics.MobilityInanimate || s.MobilityType == PvPStatics.MobilityPet); } return(output); }
public static string PlayerEndQuest(Player player, int endType) { var message = ""; IPlayerRepository playerRepo = new EFPlayerRepository(); var dbPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id); dbPlayer.InQuest = 0; dbPlayer.InQuestState = 0; playerRepo.SavePlayer(dbPlayer); IQuestRepository questRepo = new EFQuestRepository(); var questPlayerStatus = questRepo.QuestPlayerStatuses.FirstOrDefault(q => q.PlayerId == player.Id && q.QuestId == player.InQuest); if (questPlayerStatus == null) { questPlayerStatus = new QuestPlayerStatus { PlayerId = player.Id, QuestId = player.InQuest, }; } questPlayerStatus.LastEndedTurn = PvPWorldStatProcedures.GetWorldTurnNumber(); questPlayerStatus.Outcome = endType; questRepo.SaveQuestPlayerStatus(questPlayerStatus); // assing completion bonuses if (endType == (int)QuestStatics.QuestOutcomes.Completed) { var questState = GetQuestState(player.InQuestState); decimal xpGain = 0; foreach (var q in questState.QuestEnds) { // experience gain if (q.RewardType == (int)QuestStatics.RewardType.Experience) { xpGain += Int32.Parse(q.RewardAmount); } // item gain else if (q.RewardType == (int)QuestStatics.RewardType.Item) { var item = ItemStatics.GetStaticItem(System.Convert.ToInt32(q.RewardAmount)); ItemProcedures.GiveNewItemToPlayer(player, item); message += " <br>You received a <b>" + item.FriendlyName + "</b>."; } // effect gain else if (q.RewardType == (int)QuestStatics.RewardType.Effect) { var effect = EffectStatics.GetDbStaticEffect(System.Convert.ToInt32(q.RewardAmount)); EffectProcedures.GivePerkToPlayer(effect.Id, player.Id); message += "<br>You received the effect <b>" + effect.FriendlyName + "</b>."; } // spell gain else if (q.RewardType == (int)QuestStatics.RewardType.Spell) { var spell = SkillStatics.GetStaticSkill(System.Convert.ToInt32(q.RewardAmount)); SkillProcedures.GiveSkillToPlayer(player.Id, spell.Id); message += "<br>You learned the spell <b>" + spell.FriendlyName + "</b>."; } } if (xpGain > 0) { message += "<br>You earned <b>" + xpGain + "</b> XP."; } PlayerProcedures.GiveXP(player, xpGain); } // delete all of the player's quest variables var vars = QuestProcedures.GetAllQuestPlayerVariablesFromQuest(player.InQuest, player.Id).ToList(); foreach (var v in vars) { questRepo.DeleteQuestPlayerVariable(v.Id); } return(message); }
public static void SpawnAIPsychopaths(int count) { var rand = new Random(); IPlayerRepository playerRepo = new EFPlayerRepository(); var turnNumber = PvPWorldStatProcedures.GetWorldTurnNumber(); var botCount = playerRepo.Players.Count(b => b.BotId == AIStatics.PsychopathBotId); for (var i = (0 + botCount); i < (count + botCount); i++) { var cmd = new CreatePlayer { FirstName = "Psychopath", Location = LocationsStatics.GetRandomLocationNotInDungeon(), Health = 100000, MaxHealth = 100000, Mana = 100000, MaxMana = 100000, BotId = AIStatics.PsychopathBotId, UnusedLevelUpPerks = 0, XP = 0, Money = 100, LastName = NameService.GetRandomLastName(), Gender = i % 2 == 1 ? PvPStatics.GenderMale : PvPStatics.GenderFemale, }; var strength = GetPsychopathLevel(turnNumber); if (strength == 1) { cmd.Level = 1; } else if (strength == 3) { cmd.FirstName = "Fierce " + cmd.FirstName; cmd.Level = 3; } else if (strength == 5) { cmd.FirstName = "Wrathful " + cmd.FirstName; cmd.Level = 5; } else if (strength == 7) { cmd.FirstName = "Loathful " + cmd.FirstName; cmd.Level = 7; } else if (strength == 9) { cmd.FirstName = "Soulless " + cmd.FirstName; cmd.Level = 9; } var idAndFormName = GetPsychoFormFromLevelAndSex(cmd.Level, cmd.Gender); cmd.FormSourceId = idAndFormName.Item1; // assert this name isn't already taken var ghost = playerRepo.Players.FirstOrDefault(p => p.FirstName == cmd.FirstName && p.LastName == cmd.LastName); if (ghost != null) { continue; } var id = DomainRegistry.Repository.Execute(cmd); // give this bot a random skill var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList(); double max = eligibleSkills.Count; var randIndex = Convert.ToInt32(Math.Floor(rand.NextDouble() * max)); var skillToLearn = eligibleSkills.ElementAt(randIndex); SkillProcedures.GiveSkillToPlayer(id, skillToLearn.Id); // give this bot the Psychpathic perk if (strength == 1) { EffectProcedures.GivePerkToPlayer(PsychopathicForLevelOneEffectSourceId, id); } else if (strength == 3) { EffectProcedures.GivePerkToPlayer(PsychopathicForLevelThreeEffectSourceId, id); } else if (strength == 5) { EffectProcedures.GivePerkToPlayer(PsychopathicForLevelFiveEffectSourceId, id); } else if (strength == 7) { EffectProcedures.GivePerkToPlayer(PsychopathicForLevelSevenEffectSourceId, id); } else if (strength == 9) { EffectProcedures.GivePerkToPlayer(PsychopathicForLevelNineEffectSourceId, id); } // give this psycho a new rune with some random chance it is a higher level than they are, to a max of level 13 var random = new Random(Guid.NewGuid().GetHashCode()); var roll = random.NextDouble(); if (roll < .1) { strength += 4; } else if (roll < .3) { strength += 2; } var quantity = Math.Floor(random.NextDouble() * 2) + 1; // 1 or 2 for (var c = 0; c < quantity; c++) { var runeId = DomainRegistry.Repository.FindSingle(new GetRandomRuneAtLevel { RuneLevel = strength, Random = random }); DomainRegistry.Repository.Execute(new GiveRune { ItemSourceId = runeId, PlayerId = id }); } var psychoEF = playerRepo.Players.FirstOrDefault(p => p.Id == id); psychoEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(psychoEF)); playerRepo.SavePlayer(psychoEF); } }
public static (bool, string) Attack(Player attacker, Player victim, int skillSourceId) { var vm = SkillProcedures.GetSkillViewModel_NotOwned(skillSourceId); return(Attack(attacker, victim, vm)); }
private static void PerformInanimateTransformation(Player victim, Player attacker, int skillSourceId, DbStaticForm targetForm, LogBox output) { SkillProcedures.UpdateFormSpecificSkillsToPlayer(victim, targetForm.Id); DomainRegistry.Repository.Execute(new ChangeForm { PlayerId = victim.Id, FormSourceId = targetForm.Id }); if (targetForm.MobilityType == PvPStatics.MobilityInanimate && victim.BotId != AIStatics.MinibossPlushAngelId) //No reward for monsters that hurt an innocent little plush friend. :( { StatsProcedures.AddStat(victim.MembershipId, StatsProcedures.Stat__TimesInanimateTFed, 1); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__TimesInanimateTFing, 1); } else if (targetForm.MobilityType == PvPStatics.MobilityPet && victim.BotId != AIStatics.MinibossPlushAngelId) //No reward for monsters that hurt an innocent little plush friend. :( { StatsProcedures.AddStat(victim.MembershipId, StatsProcedures.Stat__TimesAnimalTFed, 1); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__TimesAnimalTFing, 1); } if (targetForm.MobilityType == PvPStatics.MobilityPet || targetForm.MobilityType == PvPStatics.MobilityInanimate) { if (victim.BotId == AIStatics.PsychopathBotId) { StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__PsychopathsDefeated, 1); } if (victim.BotId == AIStatics.ActivePlayerBotId && attacker.GameMode == (int)GameModeStatics.GameModes.PvP && victim.GameMode == (int)GameModeStatics.GameModes.PvP) { StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__PvPPlayerNumberTakedowns, 1); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__PvPPlayerLevelTakedowns, victim.Level); } } // extra log stuff for turning into item var extra = ItemProcedures.PlayerBecomesItem(victim, targetForm, attacker); output.AttackerLog += extra.AttackerLog; output.VictimLog += extra.VictimLog; output.LocationLog += extra.LocationLog; // give some of the victim's money to the attacker, the amount depending on what mode the victim is in var moneygain = victim.Money * .35M; PlayerProcedures.GiveMoneyToPlayer(attacker, moneygain); PlayerProcedures.GiveMoneyToPlayer(victim, -moneygain / 2); var levelDifference = attacker.Level - victim.Level; // only give the lump sum XP if the victim is not in the same covenant if (attacker.Covenant == null || attacker.Covenant != victim.Covenant) { var xpGain = 100 - (PvPStatics.XP__EndgameTFCompletionLevelBase * levelDifference); if (xpGain < 50) { xpGain = 50; } else if (xpGain > 200) { xpGain = 200; } // give the attacker a nice lump sum for having completed the transformation output.AttackerLog += $" <br>For having sealed your opponent into their new form, you gain an extra <b>{xpGain}</b> XP."; output.AttackerLog += PlayerProcedures.GiveXP(attacker, xpGain); } // exclude PvP score for bots if (victim.BotId == AIStatics.ActivePlayerBotId) { var score = PlayerProcedures.GetPvPScoreFromWin(attacker, victim); if (score > 0) { output.AttackerLog += PlayerProcedures.GivePlayerPvPScore(attacker, victim, score); output.VictimLog += PlayerProcedures.RemovePlayerPvPScore(victim, attacker, score); StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__DungeonPointsStolen, (float)score); } else { output.AttackerLog += $" {victim.GetFullName()} unfortunately did not have any dungeon points for you to steal for yourself."; } } // Call out a player for being the monster they are when they defeat the plush angel. if (victim.BotId == AIStatics.MinibossPlushAngelId) { output.AttackerLog += "<br><br>Why did you do that to the poor plush? They just wanted to be a friend!<br>"; output.LocationLog += $"<br><b>{attacker.GetFullName()}</b> went and bullied <b>{victim.GetFullName()}</b>, like some <b>monster</b>. The angelic plush left some flowers to the 'victor', in hope they would forgive it despite doing no wrong."; // Give the dummy a bit of madness for being a bully. EffectProcedures.GivePerkToPlayer(198, attacker); } // Heals the victorious player provided that the target was eligible if (attacker.BotId == AIStatics.ActivePlayerBotId) { // Provide no healing if the victim shared a coven with the attacker if (attacker.Covenant != null && attacker.Covenant == victim.Covenant) { output.AttackerLog += " <br>There is no glory to be had in this victory, your willpower & mana are not restored."; } else { // Figure out the modifier to be used double modifier = (levelDifference * 5) / 100; // Cap the modifier to prevent too much / too little healing. if (modifier > 0.3) { modifier = 0.3; } if (modifier < -0.55) { modifier = -0.55; } decimal healingPercent = (decimal)(0.6 + modifier); if (victim.BotId != AIStatics.ActivePlayerBotId) { // The victim is not a player, provide half of the healing. healingPercent /= 2; } // Heal the attacker and restore their Mana var healingTotal = attacker.MaxHealth * healingPercent; var manaRestoredTotal = attacker.MaxMana * healingPercent; PlayerProcedures.ChangePlayerActionMana(0, healingTotal, manaRestoredTotal, attacker.Id, false); // Remove any Self Restore entires. RemoveSelfRestore(victim); output.AttackerLog += $"<br />Invigorated by your victory and fuelled by the scattered essence that was once your foe, you are healed for {healingTotal:#} willpower and {manaRestoredTotal:#} mana."; } } output.AttackerLog += $" You collect {Math.Round(moneygain, 0)} Arpeyjis your victim dropped during the transformation."; // create inanimate XP for the victim InanimateXPProcedures.GetStruggleChance(victim, false); // if this victim is a bot, clear out some old stuff that is not needed anymore if (victim.BotId < AIStatics.ActivePlayerBotId) { AIDirectiveProcedures.DeleteAIDirectiveByPlayerId(victim.Id); PlayerLogProcedures.ClearPlayerLog(victim.Id); } TFEnergyProcedures.DeleteAllPlayerTFEnergiesOfFormSourceId(victim.Id, targetForm.Id); // if the attacker is a psycho, have them change to a new spell and equip whatever they just earned if (attacker.BotId == AIStatics.PsychopathBotId) { SkillProcedures.DeletePlayerSkill(attacker, skillSourceId); if (targetForm.MobilityType == PvPStatics.MobilityInanimate || targetForm.MobilityType == PvPStatics.MobilityPet) { if (attacker.MembershipId.IsNullOrEmpty()) { // give this bot a random replacement inanimate/pet skill var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList(); var rand = new Random(); var skillToLearn = eligibleSkills.ElementAt(rand.Next(eligibleSkills.Count)); SkillProcedures.GiveSkillToPlayer(attacker.Id, skillToLearn.Id); } else { // Bot is being controlled by a player - re-add the original skill so only the ordering of skills changes SkillProcedures.GiveSkillToPlayer(attacker.Id, skillSourceId); } } } }