public static void EndEvent(Player donna)
        {
            PvPWorldStatProcedures.Boss_EndDonna();
            var damages = AIProcedures.GetTopAttackers(-4, 20);
            IPlayerRepository playerRepo = new EFPlayerRepository();

            // top player gets 800 XP, each player down the line receives 35 fewer
            var i         = 0;
            var maxReward = 800;

            for (var r = 0; r < damages.Count; r++)
            {
                var damage = damages.ElementAt(r);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (i * 40);
                victor.XP += reward;
                i++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + donna.GetFullName() + ", you earn " + reward + " XP from your spells cast against the mythical sorceress.</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.DONNA_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
Example #2
0
        public static void CounterAttack(Player victim, Player boss)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();

            // boss counterattacks once
            AttackProcedures.Attack(boss, victim, ChooseSpell(victim));

            // have some of the followers also attack the agressor
            var allFollowers  = GetFollowers();
            var followersHere = allFollowers.Where(f => f.dbLocationName == boss.dbLocationName &&
                                                   f.Id != victim.Id &&
                                                   f.TimesAttackingThisUpdate < 3 &&
                                                   f.ActionPoints >= PvPStatics.AttackCost
                                                   ).ToList();


            for (var i = 0; i < allFollowers.Count / 2; i++)
            {
                var follower = GetRandomFollower(followersHere);
                if (follower != null)
                {
                    AttackProcedures.Attack(follower, victim, ChooseSpell(victim));
                    PlayerLogProcedures.AddPlayerLog(follower.Id, $"<b>{BossFirstName} {BossLastName} orders you to attack {victim.GetFullName()}!</b>", true);

                    // reset the last attack and online timestamp to before the attack, otherwise she bumps her followers online indefinitely...
                    var player = playerRepo.Players.First(p => p.Id == follower.Id);
                    player.LastActionTimestamp = follower.LastActionTimestamp;
                    player.LastCombatTimestamp = follower.LastCombatTimestamp;
                    playerRepo.SavePlayer(player);

                    // remove this person from the list of eligible attackers so they don't do it more than once
                    followersHere = followersHere.Where(f => f.Id != follower.Id).ToList();
                }
            }
        }
Example #3
0
        public static void CounterAttack(Player human, Player bimboss)
        {
            // record that human attacked the boss
            AIProcedures.DealBossDamage(bimboss, human, true, 1);

            // if the bimboboss is inanimate, end this boss event
            if (bimboss.Mobility != PvPStatics.MobilityFull)
            {
                return;
            }

            // if the player doesn't currently have it, give them the infection kiss
            if (!EffectProcedures.PlayerHasEffect(human, KissEffectSourceId) && !EffectProcedures.PlayerHasEffect(human, CureEffectSourceId))
            {
                AttackProcedures.Attack(bimboss, human, KissSkillSourceId);
                AIProcedures.DealBossDamage(bimboss, human, false, 1);
            }

            // otherwise run the regular trasformation
            else if (human.FormSourceId != RegularBimboFormSourceId)
            {
                var rand        = new Random(Guid.NewGuid().GetHashCode());
                var attackCount = (int)Math.Floor(rand.NextDouble() * 2 + 1);
                for (var i = 0; i < attackCount; i++)
                {
                    AttackProcedures.Attack(bimboss, human, RegularTFSpellSourceId);
                }
                AIProcedures.DealBossDamage(bimboss, human, false, attackCount);
            }

            // otherwise make the human wander away to find more targets
            else
            {
                var targetLocation = GetLocationWithMostEligibleTargets();
                var newlocation    = AIProcedures.MoveTo(human, targetLocation, 9);

                IPlayerRepository playerRepo = new EFPlayerRepository();
                var dbHuman = playerRepo.Players.FirstOrDefault(p => p.Id == human.Id);
                dbHuman.TimesAttackingThisUpdate = PvPStatics.MaxAttacksPerUpdate;
                dbHuman.Health         = 0;
                dbHuman.Mana           = 0;
                dbHuman.XP            -= 25;
                dbHuman.dbLocationName = newlocation;
                dbHuman.ActionPoints  -= 10;

                if (dbHuman.XP < 0)
                {
                    dbHuman.XP = 0;
                }

                if (dbHuman.ActionPoints < 0)
                {
                    dbHuman.ActionPoints = 0;
                }

                playerRepo.SavePlayer(dbHuman);
                var message = "Lady Lovebringer is not pleased with you attacking her after she has so graciously given you that sexy body and carefree mind.  She whispers something into your ear that causes your body to grow limp in her arms, then injects you with a serum that makes your mind just a bit foggier and loyal to your bimbonic mother.  She orders you away to find new targets to spread the virus to.  The combination of lust and her command leaves you with no choice but to mindlessly obey...";
                PlayerLogProcedures.AddPlayerLog(human.Id, message, true);
            }
        }
        private static IEnumerable <InstinctData> StripperActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand)
        {
            // Strippers - remove random item
            var mcStrippers = mcPlayers.Where(p => JokeShopProcedures.STRIPPERS.Any(stripperForm => p.FormSourceId == stripperForm)).ToList();

            foreach (var stripper in mcStrippers)
            {
                var stripperPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == stripper.Id);
                var stripperItems  = ItemProcedures.GetAllPlayerItems(stripperPlayer.Id)
                                     .Where(i => i.dbItem.IsEquipped &&
                                            i.Item.ItemType != PvPStatics.ItemType_Pet &&
                                            i.Item.ItemType != PvPStatics.ItemType_Consumable &&
                                            i.Item.ItemType != PvPStatics.ItemType_Consumable_Reuseable).ToList();

                if (stripperItems.Any())
                {
                    string[] adverbs    = { "seductively", "cautiously", "flirtatiously", "cheekily", "obediently", "enthusiastically", "reluctantly", "hesitantly", "energetically", "sheepishly" };
                    var      adverb     = adverbs[rand.Next(adverbs.Count())];
                    var      itemToDrop = stripperItems[rand.Next(stripperItems.Count())];

                    PlayerLogProcedures.AddPlayerLog(stripper.Id, $"You {adverb} remove your <b>{itemToDrop.Item.FriendlyName}</b>!", true);
                    LocationLogProcedures.AddLocationLog(stripper.dbLocationName, $"{stripperPlayer.GetFullName()} {adverb} removes their <b>{itemToDrop.Item.FriendlyName}</b>!");
                    ItemProcedures.DropItem(itemToDrop.dbItem.Id);
                }

                mcPlayers = mcPlayers.Where(p => p.Id != stripper.Id);
            }

            return(mcPlayers);
        }
Example #5
0
        public static string OpenPsychoNip(Player player)
        {
            IAIDirectiveRepository directiveRepo = new EFAIDirectiveRepository();
            var idleBots = directiveRepo.AIDirectives.Where(d => d.State == "idle")
                           .Select(d => d.OwnerId)
                           .ToArray();

            // Set three lowest level psychos without targets on the player
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var botsToAttract            = playerRepo.Players.Where(p => idleBots.Contains(p.Id) &&
                                                                    p.BotId == AIStatics.PsychopathBotId &&
                                                                    p.Mobility == PvPStatics.MobilityFull)
                                           .OrderBy(p => p.Level)
                                           .Select(p => p.Id)
                                           .Take(3)
                                           .ToArray();

            foreach (var botId in botsToAttract)
            {
                AIDirectiveProcedures.SetAIDirective_Attack(botId, player.Id);
            }

            PlayerLogProcedures.AddPlayerLog(player.Id, $"You open a tin pf PsychoNip", false);
            LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} opened a tin of PsychoNip!");

            return("You spot a tin with a colorful insignia on a shelf.  You move over to take a closer look, but accidentally knock the tin to the floor and spill its contents!  You gather up the fallen leaves and place them back in the tin.  \"PsychoNip,\" it reads.  Perhaps you should stay alert for the next few turns in case the scent has caught anyone's attention...");
        }
        public static void EndEvent(int newOwnerId)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            IItemRepository   itemRepo   = new EFItemRepository();

            var valentine = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.ValentineBotId);


            var panties = itemRepo.Items.FirstOrDefault(i => i.ItemSourceId == QueensPantiesItemSourceId);

            panties.OwnerId = newOwnerId;
            itemRepo.SaveItem(panties);

            DomainRegistry.Repository.Execute(new DropAllItems {
                PlayerId = valentine.Id, IgnoreRunes = true
            });
            DomainRegistry.Repository.Execute(new DeletePlayer {
                PlayerId = valentine.Id
            });

            PvPWorldStatProcedures.Boss_EndValentine();

            // find the players who dealt the most damage and award them with XP
            var damages = AIProcedures.GetTopAttackers(valentine.BotId, 15);

            // top player gets 500 XP, each player down the line receives 25 fewer
            var l         = 0;
            var maxReward = 500;

            for (var r = 0; r < damages.Count; r++)
            {
                var damage = damages.ElementAt(r);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 30);
                victor.XP += reward;
                l++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your valiant (maybe foolish?) efforts in challenging " + valentine.GetFullName() + " you receieve " + reward + " XP from your risky struggle!</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (r <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.VAMPIRE_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
Example #7
0
        public static string ForceAttack(Player attacker, bool strongAttackerAlerts = false, Random rand = null)
        {
            if (attacker.TimesAttackingThisUpdate >= PvPStatics.MaxAttacksPerUpdate)
            {
                return(null);
            }

            if (attacker.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return(null);
            }

            rand = rand ?? new Random();
            var candidates = JokeShopProcedures.ActivePlayersInJokeShopApartFrom(attacker)
                             .Where(p => p.GameMode == (int)GameModeStatics.GameModes.PvP &&
                                    JokeShopProcedures.PlayerHasBeenWarned(p)).ToList();

            if (candidates == null || candidates.IsEmpty())
            {
                return(null);
            }

            var victim = candidates[rand.Next(candidates.Count())];

            var spells = SkillProcedures.AvailableSkills(attacker, victim, true);

            if (spells == null || spells.IsEmpty())
            {
                return(null);
            }

            var spellList = spells.ToArray();
            var spell     = spellList[rand.Next(spellList.Count())];

            var message = $"You are compelled to attack {victim.GetFullName()}!";

            PlayerLogProcedures.AddPlayerLog(attacker.Id, message, strongAttackerAlerts);
            PlayerLogProcedures.AddPlayerLog(victim.Id, $"{attacker.GetFullName()} is compelled to attack you!", true);
            LocationLogProcedures.AddLocationLog(attacker.dbLocationName, $"{attacker.GetFullName()} is compelled to attack {victim.GetFullName()}!");

            // Note we do not apply the full gamut of preconditions of a manual attack present in the controller
            var attack = AttackProcedures.AttackSequence(attacker, victim, spell, false);

            if (strongAttackerAlerts)
            {
                PlayerLogProcedures.AddPlayerLog(attacker.Id, attack, true);
            }

            return($"{message}<br />{attack}");
        }
Example #8
0
        public virtual ActionResult RevertToBase(int Id)
        {
            // Get Moderator info.
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            var checkModerator = User.IsInRole(PvPStatics.Permissions_Moderator);

            if (!checkModerator)
            {
                TempData["Result"] = "You do not have permission to do that.";
                return(RedirectToAction(MVC.PvP.LookAtPlayer(Id)));
            }

            // Get the player info needed
            var playerMembershipId = PlayerProcedures.GetPlayer(Id);

            IPlayerRepository playerRepo = new EFPlayerRepository();

            var player = playerRepo.Players.FirstOrDefault(p => p.MembershipId == playerMembershipId.MembershipId);

            if (player.Mobility != PvPStatics.MobilityFull)
            {
                TempData["Result"] = "Only animate players can be force reverted to base form.";
                return(RedirectToAction(MVC.PvP.LookAtPlayer(Id)));
            }

            // Check for empty field
            if (player.OriginalFirstName == null || player.OriginalLastName == null)
            {
                TempData["Result"] = "The player is missing their original first or last name. Please contact an admin to get this fixed.";
                return(RedirectToAction(MVC.PvP.LookAtPlayer(Id)));
            }

            // Revert the player to their original self.
            player.FirstName = player.OriginalFirstName;
            player.LastName  = player.OriginalLastName;

            playerRepo.SavePlayer(player);

            DomainRegistry.Repository.Execute(new ChangeForm
            {
                PlayerId     = Id,
                FormSourceId = player.OriginalFormSourceId
            });

            PlayerLogProcedures.AddPlayerLog(me.Id,
                                             $"<b>You have reverted {player.OriginalFirstName} {player.OriginalLastName} back to their starting identity.</b>", true);
            return(RedirectToAction(MVC.PvP.Play()));
        }
        private static IEnumerable <InstinctData> MaidActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand)
        {
            // Maids - find places to clean
            var mcMaids = mcPlayers.Where(p => JokeShopProcedures.MAIDS.Any(maidForm => p.FormSourceId == maidForm)).ToList();

            foreach (var maid in mcMaids)
            {
                var maidPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == maid.Id);
                var maidLoc    = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == maidPlayer.dbLocationName);

                if (maidLoc != null)
                {
                    string nextLoc;
                    string newContract = "";

                    string[] cleaningContracts = { "coffee_shop", "tavern", "oldoak_apartments", "mansion", "ranch_inside", "castle", "salon" };
                    if (cleaningContracts.Contains(maidLoc.Region))
                    {
                        nextLoc = LocationsStatics.GetRandomLocation_InRegion(maidLoc.Region);
                    }
                    else
                    {
                        newContract = "One of the local facilities has just signed a new contract with you!  ";
                        nextLoc     = LocationsStatics.GetRandomLocation_InRegion(cleaningContracts[rand.Next(cleaningContracts.Count())]);
                    }

                    var stoppedAt = EnvironmentPrankProcedures.MovePlayer(maidPlayer, nextLoc, 20, timestamp: false);

                    if (stoppedAt == nextLoc || maidPlayer.dbLocationName == nextLoc)
                    {
                        var      here       = LocationsStatics.GetConnectionName(nextLoc);
                        string[] activities = { "dusting away the cobwebs", "vaccuuming the floor", "washing up the dishes", "doing the laundry", "serving refreshments", "sweeping the trash", "handing out freshly baked cupcakes" };
                        var      activity   = activities[rand.Next(activities.Count())];

                        PlayerLogProcedures.AddPlayerLog(maidPlayer.Id, $"{newContract}You arrive at <b>{here}</b> and start {activity}!", true);
                        LocationLogProcedures.AddLocationLog(nextLoc, $"{maidPlayer.GetFullName()} arrives here and starts <b>{activity}</b>.");
                    }
                    else if (stoppedAt != null)
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        PlayerLogProcedures.AddPlayerLog(maidPlayer.Id, $"{newContract}You quickly head to your new job but only get as far as <b>{here}</b>.", true);
                    }
                }

                mcPlayers = mcPlayers.Where(p => p.Id != maid.Id);
            }

            return(mcPlayers);
        }
Example #10
0
        public static string AwardChallenge(Player player, int minDuration, int maxDuration, bool?withPenalties = null, Random rand = null)
        {
            var challenge = ChallengeProcedures.AwardChallenge(player, minDuration, maxDuration, withPenalties);

            var message = DescribeChallenge(player, challenge, rand);

            if (message == null)
            {
                return(null);
            }

            PlayerLogProcedures.AddPlayerLog(player.Id, message, true);

            return("You have been set a challenge!");
        }
Example #11
0
        public static void CounterAttack(Player demon, Player attacker)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var dbDemon = playerRepo.Players.FirstOrDefault(f => f.Id == demon.Id);

            if (dbDemon.Mobility != PvPStatics.MobilityFull)
            {
                decimal xpGain     = 30 + 5 * dbDemon.Level;
                decimal pointsGain = dbDemon.Level * 2;
                PlayerProcedures.GivePlayerPvPScore_NoLoser(attacker, pointsGain);
                var playerLog = "You absorb dark magic from your vanquished opponent, earning " + pointsGain + " points and " + xpGain + " XP.  Unfortunately the demon's new form fades into mist, denying you any other trophies of your conquest.";
                PlayerLogProcedures.AddPlayerLog(attacker.Id, playerLog, true);
                PlayerProcedures.GiveXP(attacker, xpGain);

                var item = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer {
                    PlayerId = dbDemon.Id
                });
                ItemProcedures.DeleteItem(item.Id);

                DomainRegistry.Repository.Execute(new DeletePlayer {
                    PlayerId = demon.Id
                });

                StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__DungeonDemonsDefeated, 1);
            }
            else if (dbDemon != null && dbDemon.Mobility == PvPStatics.MobilityFull && attacker.Mobility == PvPStatics.MobilityFull)
            {
                var(complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId);

                if (!complete)
                {
                    (complete, _) = AttackProcedures.Attack(dbDemon, attacker, PvPStatics.Dungeon_VanquishSpellSourceId);
                }

                var dbDemonBuffs = ItemProcedures.GetPlayerBuffs(dbDemon);
                if (dbDemon.Mana < PvPStatics.AttackManaCost * 6)
                {
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = dbDemon.Id, Buffs = dbDemonBuffs, NoValidate = true
                    });
                }

                if (complete)
                {
                    AIProcedures.EquipDefeatedPlayer(dbDemon, attacker);
                }
            }
        }
Example #12
0
        public virtual ActionResult SetSoulbindingConsent(bool isConsenting)
        {
            var me = PlayerProcedures.GetPlayerFromMembership(User.Identity.GetUserId());

            try
            {
                TempData["Result"] = DomainRegistry.Repository.Execute(new SetSoulbindingConsent {
                    PlayerId = me.Id, IsConsenting = isConsenting
                });
            }
            catch (DomainException e)
            {
                TempData["Error"] = e.Message;
            }

            IItemRepository itemRep     = new EFItemRepository();
            var             inanimateMe = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer {
                PlayerId = me.Id
            });

            if (inanimateMe.Owner != null)
            {
                var formRepo = new EFDbStaticFormRepository();
                var form     = formRepo.DbStaticForms.FirstOrDefault(f => f.Id == me.FormSourceId);

                if (isConsenting)
                {
                    PlayerLogProcedures.AddPlayerLog(inanimateMe.Owner.Id, $"{me.GetFullName()}, your {form.FriendlyName}, has agreed to let you soulbind them!", true);
                }
                else
                {
                    PlayerLogProcedures.AddPlayerLog(inanimateMe.Owner.Id, $"{me.GetFullName()}, your {form.FriendlyName}, has withdrawn their soulbinding consent.", false);
                }
            }

            if (isConsenting)
            {
                PlayerLogProcedures.AddPlayerLog(me.Id, $"You have consented to soulbinding.", false);
            }
            else
            {
                PlayerLogProcedures.AddPlayerLog(me.Id, $"You have withdrawn soulbinding consent.", false);
            }

            return(RedirectToAction(MVC.PvP.Play()));
        }
        private static bool Teleport(Player player, string location, bool logLocations)
        {
            if (location == null)
            {
                return(false);
            }

            var destination = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == location);

            if (destination == null)
            {
                return(false);
            }

            if (player.InDuel > 0 || player.InQuest > 0 || player.MindControlIsActive || player.MoveActionPointDiscount < -TurnTimesStatics.GetActionPointReserveLimit())
            {
                return(false);
            }

            if (ItemProcedures.GetAllPlayerItems(player.Id).Count(i => !i.dbItem.IsEquipped) > PvPStatics.MaxCarryableItemCountBase + player.ExtraInventory)
            {
                // Carryiing too much
                return(false);
            }

            if (destination.dbName.Contains("dungeon_"))
            {
                SkillProcedures.GiveSkillToPlayer(player.Id, PvPStatics.Dungeon_VanquishSpellSourceId);
            }

            PlayerProcedures.MovePlayer_InstantNoLog(player.Id, location);

            if (logLocations)
            {
                LocationLogProcedures.AddLocationLog(player.dbLocationName, $"Strange forces propel {player.GetFullName()} off to {destination.Name}!");
            }
            else
            {
                LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} is whisked off to a faraway place!");
            }
            LocationLogProcedures.AddLocationLog(location, $"{player.GetFullName()} is surprised to find they are suddenly here!");
            PlayerLogProcedures.AddPlayerLog(player.Id, $"You are sent to {destination.Name}", false);

            return(true);
        }
Example #14
0
        public static string PlaceBountyOnPlayersHead(Player player, Random rand = null)
        {
            // Only place bounties on PvP players
            if (player.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return(null);
            }

            rand = rand ?? new Random();
            var bountyEffectSourceId = BountyProcedures.PlaceBounty(player, rand);

            if (!bountyEffectSourceId.HasValue)
            {
                return(null);
            }

            var details = BountyProcedures.BountyDetails(player, bountyEffectSourceId.Value);

            if (details == null)
            {
                return(null);
            }

            StatsProcedures.AddStat(player.MembershipId, StatsProcedures.Stat__BountyCount, 1);

            // Put up some wanted posters
            var locations       = LocationsStatics.LocationList.GetLocation.Select(l => l.dbName).ToList();
            var locationMessage = $"<b>Wanted:</b>  A reward is on offer to whoever turns <b>{player.GetFullName()}</b> into a <b>{details.Form?.FriendlyName}</b>!";

            for (var i = 0; i < 10; i++)
            {
                var loc = locations[rand.Next(locations.Count())];
                LocationLogProcedures.AddLocationLog(loc, locationMessage);
                locations.Remove(loc);
            }

            var playerMessage = $"The spirits in the store are enraged by your actions!  They are too out of phase to attack you directly and instead choose to place a bounty on your head!  Beware of the townspeople trying to turn you into a <b>{details.Form?.FriendlyName}</b>!";

            PlayerLogProcedures.AddPlayerLog(player.Id, playerMessage, true);

            return(playerMessage);
        }
Example #15
0
        public virtual ActionResult AdvanceTurn()
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            if (me.InDuel <= 0)
            {
                TempData["Error"] = "You are not in a duel.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var duel = DuelProcedures.GetDuel(me.InDuel);

            var combatants = DuelProcedures.GetPlayerViewModelsInDuel(duel.Id);

            if (!PvPStatics.ChaosMode)
            {
                foreach (var p in combatants)
                {
                    if (p.Player.TimesAttackingThisUpdate < PvPStatics.MaxAttacksPerUpdate)
                    {
                        TempData["Error"] = "Cannot advance this turn." + p.Player.GetFullName() + " has not used up all of their attacks.";
                        return(RedirectToAction(MVC.PvP.Play()));
                    }
                }
            }

            foreach (var p in combatants)
            {
                PlayerProcedures.SetAttackCount(p.Player.ToDbPlayer(), 0);
                PlayerProcedures.SetCleanseMeditateCount(p.Player.ToDbPlayer(), 0);
                var message = "<b>" + me.GetFullName() + " has advanced the duel turn.  Attacks and cleanse/meditate limits have been reset.  Attacks may resume in 20 seconds.</b>";
                PlayerLogProcedures.AddPlayerLog(p.Player.Id, message, true);
                NoticeService.PushNotice(p.Player.Id, message, NoticeService.PushType__PlayerLog);
            }

            DuelProcedures.SetLastDuelAttackTimestamp(duel.Id);

            TempData["Result"] = "Duel turn advanced.  All combatants have had their attack and cleanse/meditate limits reset.  Attacks may resume in 20 seconds.";
            return(RedirectToAction(MVC.PvP.Play()));
        }
Example #16
0
        /// <summary>
        /// End the boss event and distribute XP to players who fought
        /// </summary>
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndMotorcycleGang();
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var damages = AIProcedures.GetTopAttackers(AIStatics.MotorcycleGangLeaderBotId, 25);

            // top player gets 1000 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 1000;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);

                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                playerRepo.SavePlayer(victor);
                PlayerLogProcedures.AddPlayerLog(victor.Id, $"<b>For your contribution in defeating {BossFirstName} {BossLastName}, you earn {reward} XP from your spells cast against her</b>", true);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.MOTORCYCLE_RUNE, PlayerId = victor.Id
                    });                                                                                                                   // TODO:  Make new rune for this boss
                }
            }
        }
Example #17
0
        /// <summary>
        /// End the faeboss boss event and distribute XP to players who fought her
        /// </summary>
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndFaeBoss();
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var damages = AIProcedures.GetTopAttackers(AIStatics.FaebossBotId, 25);

            // top player gets 1000 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 1000;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);

                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                playerRepo.SavePlayer(victor);
                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + FirstName + " " + LastName + ", you earn " + reward + " XP from your spells cast against traitorous fae.</b>", true);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.NARCISSA_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
        private static IEnumerable <InstinctData> GhostActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, Random rand)
        {
            // Ghosts - haunt old buildings
            var mcGhosts = mcPlayers.Where(p => JokeShopProcedures.GHOSTS.Any(ghostForm => p.FormSourceId == ghostForm)).ToList();

            foreach (var ghost in mcGhosts)
            {
                var ghostPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == ghost.Id);
                var ghostLoc    = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == ghostPlayer.dbLocationName);

                if (ghostLoc != null)
                {
                    string nextLoc;

                    string[] haunts = { "mansion", "castle" };
                    if (haunts.Contains(ghostLoc.Region))
                    {
                        nextLoc = LocationsStatics.GetRandomLocation_InRegion(ghostLoc.Region);
                    }
                    else
                    {
                        nextLoc = LocationsStatics.GetRandomLocation_InRegion(haunts[rand.Next(haunts.Count())]);
                    }

                    // Check whether we can haunt the current tile
                    // An enhancement would be to allow ghosts to move through walls
                    var stoppedAt = EnvironmentPrankProcedures.MovePlayer(ghostPlayer, nextLoc, 20, timestamp: false);

                    var canHaunt = stoppedAt == nextLoc || ghostPlayer.dbLocationName == nextLoc;

                    if (!canHaunt && stoppedAt != null)
                    {
                        var stoppedAtTile = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == stoppedAt);
                        canHaunt = haunts.Contains(stoppedAtTile.Region);
                    }

                    if (canHaunt)
                    {
                        var here   = LocationsStatics.GetConnectionName(nextLoc);
                        var cutoff = DateTime.UtcNow.AddMinutes(-TurnTimesStatics.GetOfflineAfterXMinutes());

                        var candidates = playerRepo.Players
                                         .Where(p => p.dbLocationName == nextLoc &&
                                                p.LastActionTimestamp >= cutoff &&
                                                p.Id != ghostPlayer.Id &&
                                                p.Mobility == PvPStatics.MobilityFull &&
                                                p.InDuel <= 0 &&
                                                p.InQuest <= 0 &&
                                                p.BotId == AIStatics.ActivePlayerBotId)
                                         .ToList();

                        if (candidates.Any())
                        {
                            var      victim = candidates[rand.Next(candidates.Count())];
                            string[] calls  = { "Boo!", "Whooo!" };
                            var      call   = calls[rand.Next(calls.Count())];

                            PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"After entering {here} you tap {victim.GetFullName()} on the shoulder and shout <b>\"{call}\"</b>!", true);
                            PlayerLogProcedures.AddPlayerLog(victim.Id, $"{ghostPlayer.GetFullName()} taps you on the shoulder and shouts <b>\"{call}\"</b>!", true);
                            LocationLogProcedures.AddLocationLog(nextLoc, $"{ghostPlayer.GetFullName()} shouts <b>\"{call}\"</b> at {victim.GetFullName()}.");
                        }
                        else
                        {
                            string[] activities = { "rattles some chains", "wails like a banshee", "floats through a wall", "lights a candle", "makes the lights flicker", "fades into the background", "knocks a book off a shelf", "melts into a pool of ectoplasm", "sends a a chill through the air" };
                            var      activity   = activities[rand.Next(activities.Count())];

                            PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"You begin haunting {here}!", true);
                            LocationLogProcedures.AddLocationLog(nextLoc, $"<b>{ghostPlayer.GetFullName()} {activity}</b>.");
                        }
                    }
                    else if (stoppedAt != null)
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        PlayerLogProcedures.AddPlayerLog(ghostPlayer.Id, $"The spirits call you to <b>{here}</b>.", true);
                    }
                }

                mcPlayers = mcPlayers.Where(p => p.Id != ghost.Id);
            }

            return(mcPlayers);
        }
Example #19
0
        public static void EndEvent()
        {
            PvPWorldStatProcedures.Boss_EndBimbo();

            // delete all bimbo effects, both the kiss and the cure
            IEffectRepository effectRepo = new EFEffectRepository();
            var effectsToDelete          = effectRepo.Effects.Where(e => e.EffectSourceId == KissEffectSourceId || e.EffectSourceId == CureEffectSourceId).ToList();

            foreach (var e in effectsToDelete)
            {
                effectRepo.DeleteEffect(e.Id);
            }

            // delete all the cure vials
            var cmd = new GetAllItemsOfType {
                ItemSourceId = CureItemSourceId
            };
            var cures = DomainRegistry.Repository.Find(cmd);

            foreach (var cure in cures)
            {
                var deleteCmd = new DeleteItem {
                    ItemId = cure.Id
                };
                DomainRegistry.Repository.Execute(deleteCmd);
            }

            // restore any bimbos back to their base form and notify them

            var message = "Your body suddenly returns to normal as the bimbonic virus in your body suddenly goes into submission, the psychic link between you and your plague mother separated for good.  Due to the bravery of your fellow mages the Bimbocalypse has been thwarted... for now.";

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var infected = playerRepo.Players.Where(p => p.FormSourceId == RegularBimboFormSourceId).ToList();

            foreach (var p in infected)
            {
                PlayerProcedures.InstantRestoreToBase(p);
                if (p.BotId == AIStatics.ActivePlayerBotId)
                {
                    PlayerLogProcedures.AddPlayerLog(p.Id, message, true);
                }
            }

            var damages = AIProcedures.GetTopAttackers(-7, 17);

            // top player gets 800 XP, each player down the line receives 35 fewer
            var l         = 0;
            var maxReward = 650;

            for (var i = 0; i < damages.Count; i++)
            {
                var damage = damages.ElementAt(i);
                var victor = playerRepo.Players.FirstOrDefault(p => p.Id == damage.PlayerId);
                if (victor == null)
                {
                    continue;
                }
                var reward = maxReward - (l * 35);
                victor.XP += reward;
                l++;

                PlayerLogProcedures.AddPlayerLog(victor.Id, "<b>For your contribution in defeating " + BossFirstName + " " + BossLastName + ", you earn " + reward + " XP from your spells cast against the plague mother.</b>", true);

                playerRepo.SavePlayer(victor);

                // top three get runes
                if (i <= 2 && victor.Mobility == PvPStatics.MobilityFull)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.BIMBO_RUNE, PlayerId = victor.Id
                    });
                }
            }
        }
        private static (IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers) CatActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers, Random rand)
        {
            // Cats - chase rodents
            var mcCats2 = mcPlayers.Where(p => JokeShopProcedures.CATS_AND_NEKOS.Any(catForm => p.FormSourceId == catForm)).ToList();

            if (!mcCats2.IsEmpty())
            {
                var mcRodents   = mcPlayers.Where(p => JokeShopProcedures.RODENTS.Any(rodentForm => p.FormSourceId == rodentForm)).ToList();
                var freeRodents = freePlayers.Where(p => JokeShopProcedures.RODENTS.Any(rodentForm => p.FormSourceId == rodentForm)).ToList();

                while (!mcCats2.IsEmpty() && mcRodents.Count() + freeRodents.Count() > 0)
                {
                    // Find a cat
                    var catIndex = rand.Next(mcCats2.Count());
                    var cat      = mcCats2[catIndex];
                    mcCats2.RemoveAt(catIndex);
                    mcPlayers = mcPlayers.Where(p => p.Id != cat.Id);

                    int    rodentId;
                    string rodentLoc;

                    // Find a rodent for them to chase
                    if (!mcRodents.IsEmpty())
                    {
                        var rodentIndex = rand.Next(mcRodents.Count());
                        var rodent      = mcRodents[rodentIndex];
                        mcRodents.RemoveAt(rodentIndex);

                        rodentId  = rodent.Id;
                        rodentLoc = rodent.dbLocationName;
                        mcPlayers = mcPlayers.Where(p => p.Id != rodentId);
                    }
                    else  // !freeRodents.IsEmpty()
                    {
                        var rodentIndex = rand.Next(freeRodents.Count);
                        var rodent      = freeRodents[catIndex];
                        freeRodents.RemoveAt(rodentIndex);

                        rodentId    = rodent.Id;
                        rodentLoc   = rodent.dbLocationName;
                        freePlayers = freePlayers.Where(p => p.Id != rodentId);
                    }

                    var catPlayer    = playerRepo.Players.FirstOrDefault(p => p.Id == cat.Id);
                    var rodentPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == rodentId);

                    // Move cat
                    var stoppedAt = EnvironmentPrankProcedures.MovePlayer(catPlayer, rodentLoc, 15, timestamp: false, callback: (p, loc) =>
                    {
                        var roll = rand.Next(4);
                        if (roll == 0)
                        {
                            LocationLogProcedures.AddLocationLog(loc, $"{catPlayer.GetFullName()} stealthily prowls the area, on the hunt for {rodentPlayer.GetFullName()}");
                        }
                    });

                    if (stoppedAt == rodentLoc)
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        LocationLogProcedures.AddLocationLog(stoppedAt, $"{catPlayer.GetFullName()} lunges at a rodent, but {rodentPlayer.GetFullName()} is too quick and evades the cat's attack!</b>");

                        PlayerLogProcedures.AddPlayerLog(rodentId, $"{catPlayer.GetFullName()} jumps out at you, but you leap from their paws and deprive them of an easy snack!", true);
                        PlayerLogProcedures.AddPlayerLog(catPlayer.Id, $"You prowl to <b>{here}</b>, creep up on {rodentPlayer.GetFullName()} and pounce!  But they're too quick and evade your clutches!", true);
                    }
                    else if (stoppedAt != null)  // Cat moved, but didn't get to the rodent's location
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        PlayerLogProcedures.AddPlayerLog(catPlayer.Id, $"You prowl to <b>{here}</b>, being careful not to get too close to your prey as you prepare for the hunt...", true);
                    }
                    else if (cat.dbLocationName == rodentLoc)
                    {
                        PlayerLogProcedures.AddPlayerLog(rodentId, $"{catPlayer.GetFullName()} hides in a bush, stealthily watching you, getting ready to pounce...", true);
                        PlayerLogProcedures.AddPlayerLog(catPlayer.Id, $"You slink behind a bush and focus your eyes on {rodentPlayer.GetFullName()}, getting ready to strike...", true);
                    }
                }
            }

            return(mcPlayers, freePlayers);
        }
        private static (IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers) DogActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers, Random rand)
        {
            // Dogs - chase cats, possiby up a tree
            var mcDogs = mcPlayers.Where(p => JokeShopProcedures.DOGS.Any(dogForm => p.FormSourceId == dogForm)).ToList();

            if (!mcDogs.IsEmpty())
            {
                var mcCats   = mcPlayers.Where(p => JokeShopProcedures.CATS_AND_NEKOS.Any(catForm => p.FormSourceId == catForm)).ToList();
                var freeCats = freePlayers.Where(p => JokeShopProcedures.CATS_AND_NEKOS.Any(catForm => p.FormSourceId == catForm)).ToList();

                while (!mcDogs.IsEmpty() && mcCats.Count() + freeCats.Count() > 0)
                {
                    // Find a dog
                    var dogIndex = rand.Next(mcDogs.Count());
                    var dog      = mcDogs[dogIndex];
                    mcDogs.RemoveAt(dogIndex);
                    mcPlayers = mcPlayers.Where(p => p.Id != dog.Id);

                    int    catId;
                    string catLoc;
                    bool   catIsMindControlled;

                    // Find a cat for them to chase
                    if (!mcCats.IsEmpty())
                    {
                        var catIndex = rand.Next(mcCats.Count());
                        var cat      = mcCats[catIndex];
                        mcCats.RemoveAt(catIndex);

                        catId  = cat.Id;
                        catLoc = cat.dbLocationName;
                        catIsMindControlled = true;
                        mcPlayers           = mcPlayers.Where(p => p.Id != catId);
                    }
                    else  // !freeCats.IsEmpty()
                    {
                        var catIndex = rand.Next(freeCats.Count);
                        var cat      = freeCats[catIndex];
                        freeCats.RemoveAt(catIndex);

                        catId  = cat.Id;
                        catLoc = cat.dbLocationName;
                        catIsMindControlled = false;
                        freePlayers         = freePlayers.Where(p => p.Id != catId);
                    }

                    var dogPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == dog.Id);
                    var catPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == catId);

                    // Move dog
                    var stoppedAt = EnvironmentPrankProcedures.MovePlayer(dogPlayer, catLoc, 15, timestamp: false, callback: (p, loc) =>
                    {
                        var roll = rand.Next(4);
                        if (roll == 0)
                        {
                            LocationLogProcedures.AddLocationLog(loc, $"{dogPlayer.GetFullName()} barked here as they catch the scent of a cat, {catPlayer.GetFullName()}:  <b>Woof woof!</b>");
                        }
                        else if (roll == 1)
                        {
                            LocationLogProcedures.AddLocationLog(loc, $"{dogPlayer.GetFullName()} growled here as they get closer to {catPlayer.GetFullName()}, the cat:  <b>Grrrrrrrrr!</b>");
                        }
                    });

                    // Dog has arrived at the cat's location
                    if (stoppedAt == catLoc)
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        LocationLogProcedures.AddLocationLog(stoppedAt, $"{dogPlayer.GetFullName()} barked at {catPlayer.GetFullName()}:  <b>Woof woof!</b>");

                        // If cat is mind controlled we can send them up a tree
                        if (catIsMindControlled)
                        {
                            var treeLoc = mcPlayers.FirstOrDefault(p => JokeShopProcedures.TREES.Any(treeForm => p.FormSourceId == treeForm))?.dbLocationName;

                            if (treeLoc == null)
                            {
                                treeLoc = freePlayers.FirstOrDefault(p => JokeShopProcedures.TREES.Any(treeForm => p.FormSourceId == treeForm))?.dbLocationName;
                            }

                            if (treeLoc == null)
                            {
                                treeLoc = "forest_ancestor_tree";
                            }

                            var catStoppedAt = EnvironmentPrankProcedures.MovePlayer(catPlayer, treeLoc, 15, timestamp: false, callback: (p, loc) =>
                            {
                                var roll = rand.Next(3);
                                if (roll == 0)
                                {
                                    LocationLogProcedures.AddLocationLog(loc, $"<b>Meoooww!</b> yowls {catPlayer.GetFullName()} as they quickly flee from {dogPlayer.GetFullName()}, the dog who is chasing them.");
                                }
                            });

                            if (catStoppedAt == treeLoc)
                            {
                                LocationLogProcedures.AddLocationLog(catLoc, $"{catPlayer.GetFullName()} runs to hide from {dogPlayer.GetFullName()}!");
                                LocationLogProcedures.AddLocationLog(treeLoc, $"{catPlayer.GetFullName()} leaps into a tree to hide from {dogPlayer.GetFullName()}, the dog who is chasing them.");
                                PlayerLogProcedures.AddPlayerLog(catId, $"<b>Woof woof!</b>  {dogPlayer.GetFullName()} barks at you, and you run off to the nearest tree!", true);
                                PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You chased a cat to <b>{here}</b> and started barking at {catPlayer.GetFullName()}:  <b>Woof woof!</b>.  They run off to the nearest tree to hide from you!", true);
                            }
                            else if (catStoppedAt == null)
                            {
                                PlayerLogProcedures.AddPlayerLog(catId, $"<b>Woof woof!</b>  {dogPlayer.GetFullName()} barks at you, but you can't seem to escape!", true);
                                PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You chased a cat to <b>{here}</b> and started barking at {catPlayer.GetFullName()}:  <b>Woof woof!</b>.", true);
                            }
                            else
                            {
                                LocationLogProcedures.AddLocationLog(catLoc, $"{catPlayer.GetFullName()} runs to hide from {dogPlayer.GetFullName()}!");
                                PlayerLogProcedures.AddPlayerLog(catId, $"<b>Woof woof!</b>  {dogPlayer.GetFullName()} barks at you, and you run away to try and hide!", true);
                                PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You chased a cat to <b>{here}</b> and started barking at {catPlayer.GetFullName()}:  <b>Woof woof!</b>.  They run off to try and hide from you!", true);
                            }
                        }
                        else  // Cat not mind controlled, dog can only bark
                        {
                            PlayerLogProcedures.AddPlayerLog(catId, $"{dogPlayer.GetFullName()} barked at you:  <b>Woof woof!</b>", true);
                            PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You chased a cat to <b>{here}</b> and started barking at {catPlayer.GetFullName()}:  <b>Woof woof!</b>", true);
                        }
                    }
                    else if (stoppedAt != null)  // Dog moved, but didn't get to the cat's location
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You caught scent of a cat and ran to <b>{here}</b>", true);
                    }
                    else if (dog.dbLocationName == catLoc)
                    {
                        PlayerLogProcedures.AddPlayerLog(catId, $"{dogPlayer.GetFullName()} barked at you:  <b>Woof woof!</b>", true);
                        PlayerLogProcedures.AddPlayerLog(dogPlayer.Id, $"You barked at {catPlayer.GetFullName()}:  <b>Woof woof!</b>", true);
                    }
                }
            }

            return(mcPlayers, freePlayers);
        }
Example #22
0
        public static void RunTurnLogic()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var boss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MotorcycleGangLeaderBotId);

            // motorcycle gang boss is no longer animate; end the event
            if (boss.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent();
                return;
            }

            // Step 1:  Find the most online characters (psychos and players) on the streets and move there.  Move anyone in the biker follower form to her.

            var targetLocation = GetLocationWithMostEligibleTargets();

            targetLocation = String.IsNullOrEmpty(targetLocation) ? boss.dbLocationName : targetLocation;

            var newlocation = AIProcedures.MoveTo(boss, targetLocation, 9);

            boss.dbLocationName = newlocation;
            boss.Mana           = boss.MaxMana;
            playerRepo.SavePlayer(boss);

            var followers = GetFollowers();

            // move all followers to the new location
            foreach (var follower in followers)
            {
                Player followerEF          = playerRepo.Players.First(p => p.Id == follower.Id);
                var    followerNewLocation = AIProcedures.MoveTo(follower, newlocation, 100000);

                // leave location log and penalize some 5 AP
                if (followerEF.dbLocationName != followerNewLocation)
                {
                    var newlocationFriendlyName = LocationsStatics.LocationList.GetLocation
                                                  .First(l => l.dbName == followerNewLocation).Name;

                    LocationLogProcedures.AddLocationLog(followerNewLocation, $"{followerEF.GetFullName()} rode off to <b>{newlocationFriendlyName}</b> to help protect {boss.GetFullName()}.");
                    followerEF.ActionPoints = Math.Max(0, followerEF.ActionPoints - SummonToBossAPPenalty);
                }

                followerEF.dbLocationName = followerNewLocation;

                if (follower.BotId == AIStatics.ActivePlayerBotId)
                {
                    PlayerLogProcedures.AddPlayerLog(follower.Id, $"<b>The leader of your gang, {boss.GetFullName()}, beckons for you to follow!  You have no choice but to comply.</b>", true);
                }
                else if (follower.BotId == AIStatics.PsychopathBotId)
                {
                    followerEF.Health += 25;
                    followerEF.Health  = followerEF.Health > followerEF.MaxHealth ? followerEF.MaxHealth : followerEF.Health;
                    followerEF.LastActionTimestamp = DateTime.UtcNow;
                }
                playerRepo.SavePlayer(followerEF);
            }

            // Step 2:  Give the boss the appropriate effect, determined by how many followers she has.
            EffectProcedures.GivePerkToPlayer(GetPerkSourceIdToGive(followers.Count), boss);

            // Step 3:  Attack everyone in the region 2-3 times with the biker follower spell if they are not already that form.
            var victims = GetEligibleTargetsAtLocation(newlocation);

            // try and turn everyone there into biker gang followers
            foreach (var victim in victims)
            {
                AttackProcedures.Attack(boss, victim, BikerFollowerSpellSourceId);
                AttackProcedures.Attack(boss, victim, BikerFollowerSpellSourceId);
                AttackProcedures.Attack(boss, victim, BikerFollowerSpellSourceId);
            }
        }
Example #23
0
        public static string SummonDoppelganger(Player player, Random rand = null, bool?aggro = null)
        {
            rand = rand ?? new Random();

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var cmd = new CreatePlayer
            {
                FirstName          = $"Evil {player.FirstName}",
                LastName           = player.LastName,
                Location           = player.dbLocationName,
                FormSourceId       = player.FormSourceId,
                Level              = Math.Min(9, player.Level),
                Health             = player.Health,
                MaxHealth          = player.MaxHealth,
                Mana               = player.Mana,
                MaxMana            = player.MaxMana,
                BotId              = AIStatics.PsychopathBotId,
                UnusedLevelUpPerks = 0,
                XP     = 0,
                Money  = 100 + player.Money / 10,
                Gender = player.Gender,
            };

            var botId = DomainRegistry.Repository.Execute(cmd);

            // Give spells
            var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList();

            SkillProcedures.GiveSkillToPlayer(botId, eligibleSkills[rand.Next(eligibleSkills.Count())].Id);
            SkillProcedures.GiveSkillToPlayer(botId, PvPStatics.Spell_WeakenId);

            // Give bonuses - we exclude some with no stats, with side effects, or that serve no purpose on psychos
            var sourcePerks = EffectProcedures.GetPlayerEffects2(player.Id);

            int[] effectsToExclude = { JokeShopProcedures.FIRST_WARNING_EFFECT,
                                       JokeShopProcedures.SECOND_WARNING_EFFECT,
                                       JokeShopProcedures.BANNED_FROM_JOKE_SHOP_EFFECT,
                                       JokeShopProcedures.INVISIBILITY_EFFECT,  // Ensure twin is visible, even if player can't yet attack
                                       JokeShopProcedures.PSYCHOTIC_EFFECT,     // Prevent psycho twin leaving rehab  (Sorry, Pinocchio)
                                       JokeShopProcedures.INSTINCT_EFFECT,      // Should be safe, but just to be on the safe side
                                       JokeShopProcedures.AUTO_RESTORE_EFFECT,  // No free second chances for twins, bad ends are forever
            };

            foreach (var sourcePerk in sourcePerks)
            {
                var effect = sourcePerk.dbEffect;
                if (!effectsToExclude.Contains(effect.EffectSourceId) && effect.Duration > 0)
                {
                    EffectProcedures.GivePerkToPlayer(effect.EffectSourceId, botId, effect.Duration, effect.Cooldown);
                }
            }

            // Approximately mirror the buffs the player gets from their items.
            // (Actually equipping equivalent items and runes could easily be abused so use perks)
            var itemBuffs = ItemProcedures.GetPlayerBuffs(player).ItemBuffs();

            itemBuffs += 30;  // level 1 psycho effect gives -30 stats
            if (itemBuffs >= 315)
            {
                itemBuffs -= 315;
                EffectProcedures.GivePerkToPlayer(AIProcedures.PsychopathicForLevelNineEffectSourceId, botId);
            }
            if (itemBuffs >= 225)
            {
                itemBuffs -= 225;
                EffectProcedures.GivePerkToPlayer(AIProcedures.PsychopathicForLevelSevenEffectSourceId, botId);
            }
            if (itemBuffs >= 135)
            {
                itemBuffs -= 135;
                EffectProcedures.GivePerkToPlayer(AIProcedures.PsychopathicForLevelFiveEffectSourceId, botId);
            }
            if (itemBuffs >= 70)
            {
                itemBuffs -= 70;
                EffectProcedures.GivePerkToPlayer(AIProcedures.PsychopathicForLevelThreeEffectSourceId, botId);
            }
            if (itemBuffs < 30)
            {
                itemBuffs += 30;
                EffectProcedures.GivePerkToPlayer(AIProcedures.PsychopathicForLevelOneEffectSourceId, botId);
            }

            // Give runes (round level down to odd)
            var runeLevel = cmd.Level - 1;

            runeLevel = runeLevel - (runeLevel % 2) + 1;
            var quantity = rand.Next(1, 3);

            for (var c = 0; c < quantity; c++)
            {
                var runeId = DomainRegistry.Repository.FindSingle(new GetRandomRuneAtLevel {
                    RuneLevel = runeLevel, Random = rand
                });
                DomainRegistry.Repository.Execute(new GiveRune {
                    ItemSourceId = runeId, PlayerId = botId
                });
            }

            // Balance stats
            var psychoEF = playerRepo.Players.FirstOrDefault(p => p.Id == botId);

            psychoEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(psychoEF));
            playerRepo.SavePlayer(psychoEF);

            // Tell the bot to attack the player
            if (!aggro.HasValue || aggro.Value)
            {
                AIDirectiveProcedures.SetAIDirective_Attack(botId, player.Id);
            }

            PlayerLogProcedures.AddPlayerLog(player.Id, $"<b>You have summoned your evil twin!</b>  Beware!  They are not friendly!", true);
            LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} has summoned their evil twin!");

            return("In the corner of the room is a freestanding mirror with a silver gilt frame.  You smear some of the dust off the glass to see your reflection staring back at you through the clearing in the misty haze.  As you look into it you catch sight of yourself twitching slightly, but you don't actually feel anything.  Then your reflection narrows their gaze into a scowl and steps through the rippling glazed portal, bringing you face-to-face with your mirror self!  You should be careful.  Meeting your doppelganger never ends well..");
        }
Example #24
0
        public virtual ActionResult StripVictim(int id)
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);
            var victim         = PlayerProcedures.GetPlayer(id);

            // run generic MC checks
            var errorsBox = MindControlProcedures.AssertBasicMindControlConditions(me, victim, MindControlStatics.MindControl__StripFormSourceId);

            if (errorsBox.HasError)
            {
                TempData["Error"]    = errorsBox.Error;
                TempData["SubError"] = errorsBox.SubError;
                return(RedirectToAction(MVC.MindControl.MindControlList()));
            }

            var victimItems = ItemProcedures.GetAllPlayerItems(victim.Id).ToList();

            if (victimItems.Any())
            {
                double max  = victimItems.Count();
                var    rand = new Random();
                var    num  = rand.NextDouble();

                var index      = Convert.ToInt32(Math.Floor(num * max));
                var itemToDrop = victimItems.ElementAt(index);

                MindControlProcedures.AddCommandUsedToMindControl(me, victim, MindControlStatics.MindControl__StripFormSourceId);

                var attackerMessage = "";

                if (itemToDrop.Item.ItemType != PvPStatics.ItemType_Pet)
                {
                    attackerMessage = "You commanded " + victim.GetFullName() + " to drop something.  They let go of a " + itemToDrop.Item.FriendlyName + " that they were carrying.";
                }
                else
                {
                    attackerMessage = "You commanded " + victim.GetFullName() + " to drop something.  They released their pet " + itemToDrop.Item.FriendlyName + " that they had tamed.";
                }

                PlayerLogProcedures.AddPlayerLog(me.Id, attackerMessage, false);
                TempData["Result"] = attackerMessage;

                var victimMessage = "";

                if (itemToDrop.Item.ItemType != PvPStatics.ItemType_Pet)
                {
                    victimMessage = me.GetFullName() + " commanded you to to drop something. You had no choice but to go of a " + itemToDrop.Item.FriendlyName + " that you were carrying.";
                }
                else
                {
                    victimMessage = me.GetFullName() + " commanded you to drop something. You had no choice but to release your pet " + itemToDrop.Item.FriendlyName + " that you had tamed.";
                }

                PlayerLogProcedures.AddPlayerLog(victim.Id, victimMessage, true);

                ItemProcedures.DropItem(itemToDrop.dbItem.Id);

                var locationLogMessage = victim.GetFullName() + " was forced to drop their <b>" + itemToDrop.Item.FriendlyName + "</b> by someone mind controlling them.";
                LocationLogProcedures.AddLocationLog(victim.dbLocationName, locationLogMessage);

                StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__MindControlCommandsIssued, 1);
            }
            else
            {
                TempData["Error"] = "It seems " + victim.GetFullName() + " was not carrying or wearing anything to drop!";
            }

            return(RedirectToAction(MVC.PvP.Play()));
        }
Example #25
0
        public static void ClaimReward(Player attacker, Player victim, DbStaticForm victimNewForm)
        {
            if (attacker == null || victim == null || victimNewForm == null)
            {
                return;
            }

            // Ensure victim is still in PvP, or not a player (in case we want to support bounties on NPCs)
            if (victim.BotId == AIStatics.ActivePlayerBotId && victim.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            // NPCs are not eligible to claim bounties
            if (attacker.BotId != AIStatics.ActivePlayerBotId)
            {
                return;
            }

            // Only reward PvP players to avoid friend list/alt abuse
            if (attacker.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            var bountyStaticEffectIds = MAPPINGS.Select(se => se.EffectSourceId);
            var victimEffects         = EffectProcedures.GetPlayerEffects2(victim.Id).Where(e => bountyStaticEffectIds.Contains(e.dbEffect.EffectSourceId));
            var award = 0;

            foreach (var victimEffect in victimEffects)
            {
                var bounty = BountyDetails(victim, victimEffect.dbEffect.EffectSourceId);

                if (bounty == null)
                {
                    continue;
                }

                if (victimNewForm.Id == bounty.Form?.Id)
                {
                    // Victim has been turned into the requested form - full reward
                    award = bounty.CurrentReward;
                }
                else if (victimNewForm.ItemSourceId.HasValue)
                {
                    // Award half bounty for a different inanimate form of the same type
                    IDbStaticItemRepository itemsRepo = new EFDbStaticItemRepository();
                    var itemForm = itemsRepo.DbStaticItems.FirstOrDefault(i => i.Id == victimNewForm.ItemSourceId.Value);

                    if (itemForm?.ItemType == bounty.Category)
                    {
                        award = bounty.CurrentReward / 2;
                    }
                }

                if (award > 0)
                {
                    // Release the victim from the claimed bounty
                    EffectProcedures.SetPerkDurationToZero(victimEffect.dbEffect.EffectSourceId, victim);

                    // Award bounty funds to attacker
                    PlayerLogProcedures.AddPlayerLog(attacker.Id, $"For turning {victim.GetFullName()} into a {victimNewForm.FriendlyName} you claim a bounty of {award} arpeyjis.", true);
                    PlayerProcedures.GiveMoneyToPlayer(attacker, award);

                    StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__BountiesClaimed, award);

                    break;
                }
            }
        }
        public static void CounterAttack(Player human, Player valentine)
        {
            AIProcedures.DealBossDamage(valentine, human, true, 1);

            // if Valentine's willpower is down to zero, have him hand over the panties and vanish.
            if (valentine.Health <= 0)
            {
                var victoryMessage = "'Fa-la-la-la-la la la la-la!' you recite again, pushing Lady Krampus closer to her limits. The Krampus, worn and weary from your incessant singing, frowns and shakes her head as you continue with your attack upon her. 'I grow tired of this entire charade! This isn't any fun!' she scowls and puts hands over her ears, stepping aside as if to escape your jingling. 'You win! I can't stand this! I didn't even want to stay in this accursed town, anyways!' You can feel a smile creep across your lips, happy in your attempts to erode their will. Still holding her hands upon the sides of her head, she moves to the back of the cabin and reaches into a corner. 'All I wanted to do was punish naughty boys and girls and make the holiday better, but my efforts are clearly out-classed! I feel you would do better in my place!' She continued to mutter to herself as she digs through the rubble, only relenting once they have fetched a lock-box from the debris. 'You seem to be a particularly greedy type, so I have a gift for you. Take it and do as you like with it. I'm done with this place.' She places it into your hands and in an instant, she disappears in a cloud of snow. In their parting, the ringing of caroling in your own brain seems to finally cease to free you from its curse. Shaking your head to come back to your senses, you look down at the item left for you. You cautiously open the unlocked box, finding a simple crystalline item. Much like a snowflake, its form looks rather delicate and fragile.";

                PlayerLogProcedures.AddPlayerLog(human.Id, victoryMessage, true);

                EndEvent(human.Id);
            }

            // Valentine is fine, do counterattack
            else
            {
                // regular counterattacks, not berserk
                if (valentine.Health > valentine.MaxHealth / 4)
                {
                    //Gingerbread Boys and Candy Cane Girls
                    if (human.Gender == PvPStatics.GenderMale)
                    {
                        AttackProcedures.Attack(valentine, human, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(valentine, human, BoySpellSourceID);
                        AttackProcedures.Attack(valentine, human, BoySpellSourceID);
                        AIProcedures.DealBossDamage(valentine, human, false, 3);
                    }
                    else
                    {
                        AttackProcedures.Attack(valentine, human, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(valentine, human, GirlSpellSourceID);
                        AttackProcedures.Attack(valentine, human, GirlSpellSourceID);
                        AIProcedures.DealBossDamage(valentine, human, false, 3);
                    }

                    // give this player the vampire curse if they do not yet have it
                    if (!EffectProcedures.PlayerHasEffect(human, BloodyKissEffectSourceId))
                    {
                        AttackProcedures.Attack(valentine, human, BloodyCurseSpellSourceId);
                        AIProcedures.DealBossDamage(valentine, human, false, 1);
                    }

                    // give this player the immobility curse if they do not yet have it
                    if (!EffectProcedures.PlayerHasEffect(human, ValentinesPresenceEffectSourceId))
                    {
                        AttackProcedures.Attack(valentine, human, ValentinesPresenceSpellSourceId);
                        AIProcedures.DealBossDamage(valentine, human, false, 1);
                    }
                }

                // berserk mode counterattack
                else
                {
                    // counterattack three against original attacker, and don't bother trying to turn them into a tree.
                    if (human.Gender == PvPStatics.GenderMale)
                    {
                        AttackProcedures.Attack(valentine, human, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(valentine, human, BoySpellSourceID);
                        AttackProcedures.Attack(valentine, human, BoySpellSourceID);
                        AttackProcedures.Attack(valentine, human, BoySpellSourceID);
                        AIProcedures.DealBossDamage(valentine, human, false, 4);
                    }
                    else
                    {
                        AttackProcedures.Attack(valentine, human, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(valentine, human, GirlSpellSourceID);
                        AttackProcedures.Attack(valentine, human, GirlSpellSourceID);
                        AttackProcedures.Attack(valentine, human, GirlSpellSourceID);
                        AIProcedures.DealBossDamage(valentine, human, false, 4);
                    }

                    // give this player the vampire curse if they do not yet have it
                    if (!EffectProcedures.PlayerHasEffect(human, BloodyKissEffectSourceId))
                    {
                        AttackProcedures.Attack(valentine, human, BloodyCurseSpellSourceId);
                        AIProcedures.DealBossDamage(valentine, human, false, 1);
                    }

                    // give this player the immobility curse if they do not yet have it
                    if (!EffectProcedures.PlayerHasEffect(human, ValentinesPresenceEffectSourceId))
                    {
                        AttackProcedures.Attack(valentine, human, ValentinesPresenceSpellSourceId);
                        AIProcedures.DealBossDamage(valentine, human, false, 1);
                    }

                    // attack everyone else with 1 cast for Holiday cheer.
                    var playersHere = PlayerProcedures.GetPlayersAtLocation(valentine.dbLocationName).ToList();

                    playersHere = playersHere.Where(p => p.Mobility == PvPStatics.MobilityFull &&
                                                    !PlayerProcedures.PlayerIsOffline(p) &&
                                                    p.Level >= 3 &&
                                                    p.BotId == AIStatics.ActivePlayerBotId &&
                                                    p.Id != valentine.Id &&
                                                    p.Id != human.Id &&
                                                    p.InDuel <= 0 &&
                                                    p.InQuest <= 0).ToList();

                    //People need to be more festive!
                    foreach (var p in playersHere)
                    {
                        AttackProcedures.Attack(valentine, p, TreeSpellSourceID);
                        AIProcedures.DealBossDamage(valentine, p, false, 1);
                    }
                }
            }
        }
        public static void RunDonnaActions()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();

            var worldTurnNumber = PvPWorldStatProcedures.GetWorldTurnNumber() - 1;

            var donna = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.DonnaBotId);

            if (donna.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent(donna);
            }

            else if (donna.Mobility == PvPStatics.MobilityFull)
            {
                var donnasBuffs = ItemProcedures.GetPlayerBuffs(donna);

                // have donna meditate
                if (donna.Mana < donna.MaxMana)
                {
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = donna.Id, Buffs = donnasBuffs, NoValidate = true
                    });
                    DomainRegistry.Repository.Execute(new Meditate {
                        PlayerId = donna.Id, Buffs = donnasBuffs, NoValidate = true
                    });
                }

                var directive = AIDirectiveProcedures.GetAIDirective(donna.Id);

                if (directive.State == "attack" || directive.State == "idle")
                {
                    var target = playerRepo.Players.FirstOrDefault(p => p.Id == directive.TargetPlayerId);

                    // if Donna's target goes offline, is inanimate, or in the dungeon, have her teleport back to the ranch
                    if (target == null ||
                        target.Mobility != PvPStatics.MobilityFull ||
                        PlayerProcedures.PlayerIsOffline(target) ||
                        target.IsInDungeon() ||
                        target.InDuel > 0 ||
                        target.InQuest > 0)
                    {
                        if (donna.dbLocationName != "ranch_bedroom")
                        {
                            LocationLogProcedures.AddLocationLog(donna.dbLocationName, donna.FirstName + " " + donna.LastName + " vanished from here in a flash of smoke.");
                            donna.dbLocationName = "ranch_bedroom";
                            LocationLogProcedures.AddLocationLog(donna.dbLocationName, donna.FirstName + " " + donna.LastName + " appeared here in a flash of smoke.");
                            playerRepo.SavePlayer(donna);
                        }


                        AIDirectiveProcedures.SetAIDirective_Idle(donna.Id);
                    }

                    // Donna has a valid target; go chase it down and attack.  Donna does not look for new targets.
                    else
                    {
                        var newplace = AIProcedures.MoveTo(donna, target.dbLocationName, 10);
                        donna.dbLocationName = newplace;
                        playerRepo.SavePlayer(donna);

                        if (target.dbLocationName == newplace)
                        {
                            var rand = new Random();
                            var roll = rand.NextDouble() * 3 + 2;
                            for (var i = 0; i < roll; i++)
                            {
                                AttackProcedures.Attack(donna, target, ChooseSpell(PvPStatics.LastGameTurn));
                            }
                            AIProcedures.DealBossDamage(donna, target, false, (int)roll);
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                }

                // have Donna equip all the pets she owns
                IItemRepository    itemRepo    = new EFItemRepository();
                IEnumerable <Item> donnasItems = itemRepo.Items.Where(i => i.OwnerId == donna.Id && !i.IsEquipped && i.Level > 3);
                var itemsToEquip = new List <Item>();
                foreach (var i in donnasItems)
                {
                    itemsToEquip.Add(i);
                }
                foreach (var i in itemsToEquip)
                {
                    i.IsEquipped     = true;
                    i.dbLocationName = donna.dbLocationName;
                    itemRepo.SaveItem(i);
                }

                //The list should only look at pets.
                var donnasPlayerPets = DomainRegistry.Repository.Find(new GetItemsOwnedByPlayer {
                    OwnerId = donna.Id
                }).Where(i => i.ItemSource.ItemType == PvPStatics.ItemType_Pet).OrderBy(i => i.Level).ToList();

                // have Donna release her weakest pet every so often
                if (worldTurnNumber % 6 == 0 && donnasPlayerPets.Any())
                {
                    var weakestItem = donnasPlayerPets.First();
                    ItemProcedures.DropItem(weakestItem.Id, donna.dbLocationName);
                    LocationLogProcedures.AddLocationLog(donna.dbLocationName, "Donna released one of her weaker pets, " + weakestItem.FormerPlayer.FullName + ", here.");
                    var luckyVictim = PlayerProcedures.GetPlayerWithExactName(weakestItem.FormerPlayer.FullName);
                    PlayerLogProcedures.AddPlayerLog(luckyVictim.Id, "Donna has released you, allowing you to wander about or be tamed by a new owner.", true);
                }
            }
        }
        private static (IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers) SheepActions(IPlayerRepository playerRepo, IEnumerable <InstinctData> mcPlayers, IEnumerable <InstinctData> freePlayers, Random rand)
        {
            // Sheep - find another sheep and follow it
            var mcSheep = mcPlayers.Where(p => JokeShopProcedures.SHEEP.Any(sheepForm => p.FormSourceId == sheepForm)).ToList();

            if (!mcSheep.IsEmpty())
            {
                var freeSheep       = freePlayers.Where(p => JokeShopProcedures.SHEEP.Any(sheepForm => p.FormSourceId == sheepForm)).ToList();
                var flockToPlayer   = -1;
                var flockToLocation = "";

                if (!freeSheep.IsEmpty())
                {
                    var target = freeSheep[rand.Next(freeSheep.Count())];
                    flockToPlayer   = target.Id;
                    flockToLocation = target.dbLocationName;
                }
                else
                {
                    flockToLocation = LocationsStatics.GetRandomLocationNotInDungeonOr(LocationsStatics.JOKE_SHOP);
                }

                foreach (var sheep in mcSheep)
                {
                    var sheepPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == sheep.Id);
                    var stoppedAt   = EnvironmentPrankProcedures.MovePlayer(sheepPlayer, flockToLocation, 15, timestamp: false, callback: (p, loc) =>
                    {
                        if (rand.Next(3) == 0)
                        {
                            LocationLogProcedures.AddLocationLog(loc, $"{p.GetFullName()} bleated here:  <b>Baaaaa!</b>");
                        }
                    });

                    if (stoppedAt == flockToLocation)
                    {
                        if (flockToPlayer >= 0)
                        {
                            PlayerLogProcedures.AddPlayerLog(flockToPlayer, $"{sheepPlayer.GetFullName()} bleated at you:  <b>Baaaaa!</b>", true);
                        }

                        LocationLogProcedures.AddLocationLog(stoppedAt, $"{sheepPlayer.GetFullName()} bleated here:  <b>Baaaaa!</b>");
                    }

                    if (stoppedAt != null)
                    {
                        var here = LocationsStatics.GetConnectionName(stoppedAt);
                        PlayerLogProcedures.AddPlayerLog(sheepPlayer.Id, $"You followed your flock to <b>{here}</b>.", true);
                    }
                }

                // Don't consider affected players for any more actions this turn
                mcPlayers = mcPlayers.Where(p => mcSheep.All(s => p.Id != s.Id));

                if (flockToPlayer >= 0)
                {
                    freePlayers = freePlayers.Where(p => p.Id != flockToPlayer);
                }
            }

            return(mcPlayers, freePlayers);
        }
Example #29
0
        public virtual ActionResult RemoveCurseSend(int curseEffectSourceId, int id)
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            // assert player is animate
            if (me.Mobility != PvPStatics.MobilityFull)
            {
                TempData["Error"] = "You must be animate in order to use this.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // assert player has not already used an item this turn
            if (me.ItemsUsedThisTurn >= PvPStatics.MaxItemUsesPerUpdate)
            {
                TempData["Error"]    = "You've already used an item this turn.";
                TempData["SubError"] = "You will be able to use another consumable next turn.";
                return(RedirectToAction(MVC.Item.MyInventory()));
            }

            // assert player owns this item
            var itemToUse = ItemProcedures.GetItemViewModel(id);

            if (itemToUse == null || itemToUse.dbItem.OwnerId != me.Id)
            {
                TempData["Error"] = "You do not own the item needed to do this.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // assert that the item can remove curses and is not any old item
            if (itemToUse.dbItem.ItemSourceId != ItemStatics.CurseLifterItemSourceId && itemToUse.dbItem.ItemSourceId != ItemStatics.ButtPlugItemSourceId)
            {
                TempData["Error"] = "This item cannot remove curses.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            var curseToRemove = EffectStatics.GetDbStaticEffect(curseEffectSourceId);

            // assert this curse is removable
            if (!curseToRemove.IsRemovable)
            {
                TempData["Error"] = "This curse is too strong to be lifted.";
                return(RedirectToAction(MVC.PvP.Play()));
            }

            // back on your feet curse/buff -- just delete outright
            if (curseToRemove.Id == PvPStatics.Effect_BackOnYourFeetSourceId)
            {
                EffectProcedures.RemovePerkFromPlayer(curseToRemove.Id, me);
            }

            // regular curse; set duration to 0 but keep cooldown
            else
            {
                EffectProcedures.SetPerkDurationToZero(curseToRemove.Id, me);
            }

            // if the item is a consumable type, delete it.  Otherwise reset its cooldown
            if (itemToUse.Item.ItemType == PvPStatics.ItemType_Consumable)
            {
                ItemProcedures.DeleteItem(itemToUse.dbItem.Id);
            }
            // else if (itemToUse.Item.ItemType == PvPStatics.ItemType_Consumable_Reuseable)
            else
            {
                ItemProcedures.ResetUseCooldown(itemToUse);
            }

            PlayerProcedures.AddItemUses(me.Id, 1);

            var result = $"You have successfully removed the curse <b>{curseToRemove.FriendlyName}</b> from your body!";

            TempData["Result"] = result;

            var playerMessage = itemToUse.Item.UsageMessage_Player;

            if (string.IsNullOrEmpty(playerMessage))
            {
                PlayerLogProcedures.AddPlayerLog(me.Id, result, false);
            }
            else
            {
                PlayerLogProcedures.AddPlayerLog(me.Id, $"{playerMessage}<br />{result}", itemToUse.dbItem.FormerPlayerId != null);
            }

            if (itemToUse.dbItem.ItemSourceId == ItemStatics.ButtPlugItemSourceId && itemToUse.dbItem.FormerPlayerId != null)
            {
                var itemMessage = itemToUse.Item.UsageMessage_Item;
                var context     = $"Your owner just used you to remove the curse <b>{curseToRemove.FriendlyName}</b>! Doesn't that make you feel all warm and tingly?";
                itemMessage = string.IsNullOrEmpty(itemMessage) ? context : $"{itemMessage}<br />{context}";
                PlayerLogProcedures.AddPlayerLog((int)itemToUse.dbItem.FormerPlayerId, itemMessage, true);
            }

            return(RedirectToAction(MVC.PvP.Play()));
        }
Example #30
0
        public static string SummonPsychopath(Player player, Random rand = null, int?strengthOverride = null, bool?aggro = null)
        {
            rand = rand ?? new Random();

            var baseStrength = Math.Min(Math.Max(0, (player.Level - 1) / 3), 3);
            var strength     = strengthOverride ?? (baseStrength + Math.Max(0, rand.Next(6) - 1));

            var prefix = "";
            int level;
            int perk;
            int?extraPerk = null;
            var gender    = rand.Next(2);
            int form;

            var turnNumber = PvPWorldStatProcedures.GetWorldTurnNumber();

            if (strength <= 0 || (turnNumber < 300 && !strengthOverride.HasValue))
            {
                strength = 0;
                level    = 1;
                perk     = AIProcedures.PsychopathicForLevelOneEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho1MId : AIProcedures.Psycho1FId;
            }
            else if (strength == 1 || (turnNumber < 600 && !strengthOverride.HasValue))
            {
                strength = 1;
                level    = 3;
                prefix   = "Fierce";
                perk     = AIProcedures.PsychopathicForLevelThreeEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho3MId : AIProcedures.Psycho3FId;
            }
            else if (strength == 2 || (turnNumber < 900 && !strengthOverride.HasValue))
            {
                strength = 2;
                level    = 5;
                prefix   = "Wrathful";
                perk     = AIProcedures.PsychopathicForLevelFiveEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho5MId : AIProcedures.Psycho5FId;
            }
            else if (strength == 3 || (turnNumber < 1500 && !strengthOverride.HasValue))
            {
                strength = 3;
                level    = 7;
                prefix   = "Loathful";
                perk     = AIProcedures.PsychopathicForLevelSevenEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho7MId : AIProcedures.Psycho7FId;
            }
            else if (strength == 4 || (turnNumber < 2400 && !strengthOverride.HasValue))
            {
                strength = 4;
                level    = 9;
                prefix   = "Soulless";
                perk     = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                form     = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }
            else if (strength == 5 || (turnNumber < 3600 && !strengthOverride.HasValue))
            {
                strength  = 5;
                level     = 11;
                prefix    = "Ruthless";
                perk      = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                extraPerk = AIProcedures.PsychopathicForLevelThreeEffectSourceId;
                form      = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }
            else
            {
                strength  = 6;
                level     = 13;
                prefix    = "Eternal";
                perk      = AIProcedures.PsychopathicForLevelNineEffectSourceId;
                extraPerk = AIProcedures.PsychopathicForLevelFiveEffectSourceId;
                form      = gender == 0 ? AIProcedures.Psycho9MId : AIProcedures.Psycho9FId;
            }

            var firstName = "Psychopath";
            var lastName  = NameService.GetRandomLastName();

            if (!prefix.IsEmpty())
            {
                firstName = $"{prefix} {firstName}";
            }

            IPlayerRepository playerRepo = new EFPlayerRepository();
            var cmd = new CreatePlayer
            {
                FirstName          = firstName,
                LastName           = lastName,
                Location           = player.dbLocationName,
                FormSourceId       = form,
                Level              = level,
                Health             = 100000,
                MaxHealth          = 100000,
                Mana               = 100000,
                MaxMana            = 100000,
                BotId              = AIStatics.PsychopathBotId,
                UnusedLevelUpPerks = 0,
                XP     = 0,
                Money  = (strength + 1) * 50,
                Gender = gender == 0 ? PvPStatics.GenderMale : PvPStatics.GenderFemale,
            };

            var botId = DomainRegistry.Repository.Execute(cmd);

            // Give spells
            var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList();

            SkillProcedures.GiveSkillToPlayer(botId, eligibleSkills[rand.Next(eligibleSkills.Count())].Id);

            if (strength >= 5)
            {
                SkillProcedures.GiveSkillToPlayer(botId, PvPStatics.Spell_WeakenId);
            }

            if (strength >= 6)
            {
                var limitedMobilityForms = JokeShopProcedures.AnimateForms().Where(f => f.Category == JokeShopProcedures.LIMITED_MOBILITY).ToArray();

                if (limitedMobilityForms.Any())
                {
                    IDbStaticSkillRepository skillsRepo = new EFDbStaticSkillRepository();

                    var formId        = limitedMobilityForms[rand.Next(limitedMobilityForms.Count())].FormSourceId;
                    var immobileSkill = skillsRepo.DbStaticSkills.FirstOrDefault(spell => spell.FormSourceId == formId);

                    if (immobileSkill != null)
                    {
                        SkillProcedures.GiveSkillToPlayer(botId, immobileSkill.Id);
                    }
                }
            }

            // Give bonuses
            EffectProcedures.GivePerkToPlayer(perk, botId);

            if (extraPerk.HasValue)
            {
                EffectProcedures.GivePerkToPlayer(extraPerk.Value, botId);
            }

            // Give runes
            var quantity = rand.Next(1, 3);

            for (var c = 0; c < quantity; c++)
            {
                var runeId = DomainRegistry.Repository.FindSingle(new GetRandomRuneAtLevel {
                    RuneLevel = strength * 2 + 1, Random = rand
                });
                DomainRegistry.Repository.Execute(new GiveRune {
                    ItemSourceId = runeId, PlayerId = botId
                });
            }

            // Balance stats
            var psychoEF = playerRepo.Players.FirstOrDefault(p => p.Id == botId);

            psychoEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(psychoEF));
            playerRepo.SavePlayer(psychoEF);

            // Tell the bot to attack the player
            if (!aggro.HasValue || aggro.Value)
            {
                AIDirectiveProcedures.SetAIDirective_Attack(botId, player.Id);
            }

            PlayerLogProcedures.AddPlayerLog(player.Id, $"<b>You have summoned {firstName} {lastName}!</b>  Beware!  They are not friendly!!", true);
            LocationLogProcedures.AddLocationLog(player.dbLocationName, $"{player.GetFullName()} has summoned <b>{firstName} {lastName}</b>!");

            return("Near the counter is an altar with a leather-bound book resting open upon it.  You take a look and try to read one of the jokes aloud.  It seems to be some consonant-heavy tongue twister that soon leaves you faltering.  You're not quite sure what the set up means, but hope the punchline will be worth it.  As you spurt out the last syllable a puff of red smoke explodes out from the book with an audible bang.  You're not laughing, and that remains the case when you close the book to see a large pentagram seared into the cover.  As the smoke subsides there seems to be a strange neon flicker to the light and a crackling to the air.  You turn sharply to see the psychopath you just summoned readying their attack against you!");
        }