Пример #1
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();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Attack an attacking player back.  There is a random chance to draw Narcissa's aggro from doing this if she has a target.  If she has no active target,
        /// the attacker instantly becomes her new target.
        /// </summary>
        /// <param name="attacker"></param>
        public static void CounterAttack(Player attacker)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var faeboss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FaebossBotId);

            AIProcedures.DealBossDamage(faeboss, attacker, true, 1); // log attack for human on boss

            var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityInanimate);

            for (var i = 0; i < 3; i++)
            {
                AttackProcedures.Attack(faeboss, attacker, spell);
                AIProcedures.DealBossDamage(faeboss, attacker, false, 1); // log attack for boss on human
            }

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

            // random chance to aggro faeboss
            var rand = new Random(Guid.NewGuid().GetHashCode());
            var num  = rand.NextDouble();

            if (num < AggroChance || directive.Var1 == 0)
            {
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var dbDirective = aiRepo.AIDirectives.FirstOrDefault(a => a.Id == directive.Id);

                dbDirective.Var1 = attacker.Id;
                aiRepo.SaveAIDirective(dbDirective);
            }
        }
Пример #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);
            }
        }
Пример #4
0
        /// <summary>
        /// Cast 1 animate spell on each player in Narcissa's current location.  She will not change her aggro for this.
        /// </summary>
        /// <param name="faeboss">Player casting the spells.  In this case, always Narcissa.</param>
        private static void CastAnimateSpellsAtLocation(Player faeboss)
        {
            var playersHere = GetEligibleTargetsInLocation(faeboss);

            foreach (var p in playersHere)
            {
                var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityFull);
                AttackProcedures.Attack(faeboss, p, spell);
                AIProcedures.DealBossDamage(faeboss, p, false, 1); // log attack for human on boss
            }
        }
Пример #5
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}");
        }
Пример #6
0
        public static void CounterAttack(Player attacker, Player bossTarget)
        {
            AIProcedures.DealBossDamage(bossTarget, attacker, true, 1);

            var spell = ChooseSpell(bossTarget);

            // nerd/bimbo counters with nerd/bimbo spell unless she has changed form
            if (bossTarget.BotId == AIStatics.MouseNerdBotId && bossTarget.FormSourceId == NerdBossFormSourceId || bossTarget.BotId == AIStatics.MouseBimboBotId && bossTarget.FormSourceId == BimboBossFormSourceId)
            {
                AttackProcedures.Attack(bossTarget, attacker, spell);
                AttackProcedures.Attack(bossTarget, attacker, spell);
                AttackProcedures.Attack(bossTarget, attacker, spell);
                AIProcedures.DealBossDamage(bossTarget, attacker, false, 3);
            }
        }
Пример #7
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);
                }
            }
        }
Пример #8
0
        public static void DonnaCounterattack(Player personAttacking, Player donna)
        {
            AIProcedures.DealBossDamage(donna, personAttacking, true, 1);

            var rand = new Random();
            var roll = rand.NextDouble() * 3;

            for (var i = 0; i < roll; i++)
            {
                AttackProcedures.Attack(donna, personAttacking, ChooseSpell(PvPStatics.LastGameTurn));
            }

            AIProcedures.DealBossDamage(donna, personAttacking, false, (int)roll);

            // if Donna is weak enough start having her mega-attack anyone in the room
            if (donna.Health < donna.MaxHealth / 5)
            {
                var PlayersHere = PlayerProcedures.GetPlayersAtLocation(donna.dbLocationName).ToList();

                foreach (var p in PlayersHere)
                {
                    if (p.BotId == AIStatics.ActivePlayerBotId &&
                        p.Level > 3 &&
                        p.Mobility == PvPStatics.MobilityFull &&
                        !PlayerProcedures.PlayerIsOffline(p) &&
                        p.Id != personAttacking.Id &&
                        p.InDuel <= 0 &&
                        p.InQuest <= 0)
                    {
                        AttackProcedures.Attack(donna, p, ChooseSpell(PvPStatics.LastGameTurn));
                        AIProcedures.DealBossDamage(donna, p, false, 1);
                    }
                }
            }


            //AIDirective directive = AIDirectiveProcedures.GetAIDirective(bot.Id);
            var directive = AIDirectiveProcedures.GetAIDirective(donna.Id);

            // if Donna has no target or by a random chance, make her target this attacker
            if (directive.TargetPlayerId == -1 || directive.State == "idle" || roll < 1)
            {
                AIDirectiveProcedures.SetAIDirective_Attack(donna.Id, personAttacking.Id);
            }
        }
Пример #9
0
        public static void CounterAttack(Player victim, Player boss)
        {
            var definition = bossData.SingleOrDefault(d => d.Value.BotId == boss.BotId);
            var world      = DomainRegistry.Repository.FindSingle(new GetWorld());

            var counterAttackTimes = GetCounterAttackTimes(boss.Health, boss.MaxHealth, world.TurnNumber);
            var complete           = false;

            for (var i = 0; i < counterAttackTimes && !complete; i++)
            {
                (complete, _) = AttackProcedures.Attack(boss, victim, ChooseSpell(boss, world.TurnNumber, definition.Value.Spells));
            }

            if (complete)
            {
                AIProcedures.EquipDefeatedPlayer(boss, victim);
            }
        }
        public static void TalkToAndCastSpell(Player player, Player valentine)
        {
            var stance = GetStance();

            // Player should not be able to attack Krampus while another boss is active.
            // This check is also made here in the event someone attempts to use a bookmark to attack the Krampus.
            if (stance == BossProcedures_Valentine.DayStance && !PvPWorldStatProcedures.IsAnyBossActive())
            {
                if (player.FormSourceId != DayVampireFemaleFormSourceId && player.FormSourceId != DayVampireMaleFormSourceId)
                {
                    if (player.Gender == PvPStatics.GenderMale)
                    {
                        AttackProcedures.Attack(valentine, player, DayVampireFemaleSpellSourceId);
                    }
                    else
                    {
                        AttackProcedures.Attack(valentine, player, DayVampireMaleSpellSourceId);
                    }
                }
            }

            /* Only have the one stance.
             * else if (stance == BossProcedures_Valentine.NightStance)
             * {
             *  if (player.FormSourceId != NightVampireFemaleFormSourceId && player.FormSourceId != NightVampireMaleFormSourceId)
             *  {
             *      if (player.Gender == PvPStatics.GenderMale)
             *      {
             *          AttackProcedures.Attack(valentine, player, NightVampireFemaleSpellSourceId);
             *      }
             *      else
             *      {
             *          AttackProcedures.Attack(valentine, player, NightVampireMaleSpellSourceId);
             *      }
             *  }
             * }
             */
        }
Пример #11
0
        public static void RunThievesAction(int turnNumber)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var malethief   = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MaleRatBotId);
            var femalethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FemaleRatBotId);
            IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
            var maleAI   = aiRepo.AIDirectives.FirstOrDefault(i => i.OwnerId == malethief.Id);
            var femaleAI = aiRepo.AIDirectives.FirstOrDefault(i => i.OwnerId == femalethief.Id);

            // both male and female are no longer animate, end boss event
            if (malethief.Mobility != PvPStatics.MobilityFull && femalethief.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent();
            }

            #region both animate
            // both male and female are animate, have them go to players and loot them!
            if (malethief.Mobility == PvPStatics.MobilityFull && femalethief.Mobility == PvPStatics.MobilityFull)
            {
                // periodically refresh list of targets
                if (turnNumber % 12 == 0)
                {
                    maleAI.sVar1 = GetRichestPlayerIds();
                    maleAI.Var1  = 0;
                }

                if (malethief.Health < malethief.MaxHealth / 6)
                {
                    var malebuffs = ItemProcedures.GetPlayerBuffs(malethief);
                    DomainRegistry.Repository.Execute(new Cleanse {
                        PlayerId = malethief.Id, Buffs = malebuffs, NoValidate = true
                    });
                    malethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MaleRatBotId);
                }

                if (femalethief.Health < femalethief.MaxHealth / 4)
                {
                    var femalebuffs = ItemProcedures.GetPlayerBuffs(femalethief);
                    DomainRegistry.Repository.Execute(new Cleanse {
                        PlayerId = femalethief.Id, Buffs = femalebuffs, NoValidate = true
                    });
                    femalethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FemaleRatBotId);
                }


                var idArray = maleAI.sVar1.Split(';');
                idArray = idArray.Take(idArray.Length - 1).ToArray();

                if (maleAI.Var1 >= idArray.Length)
                {
                    maleAI.Var1 = 0;
                }

                var targetId = Convert.ToInt32(idArray[Convert.ToInt32(maleAI.Var1)]);

                var target = playerRepo.Players.FirstOrDefault(p => p.Id == targetId);

                while ((target == null || PlayerProcedures.PlayerIsOffline(target) || target.Mobility != PvPStatics.MobilityFull || target.Money < 20) && maleAI.Var1 < idArray.Length - 1)
                {
                    maleAI.Var1++;
                    targetId = Convert.ToInt32(idArray[Convert.ToInt32(maleAI.Var1)]);
                    target   = playerRepo.Players.FirstOrDefault(p => p.Id == targetId);
                }

                // we should hopefully by now have a valid target.  Hopefully.  Now move to them and loot away.
                try {
                    // Sometimes the rats will still teleport to a person in the dungeon if they move after being targetted.
                    // Check target location again.
                    var player = PlayerProcedures.GetPlayer(target.Id);

                    // This check should prevent that at the cost of the rats losing their turn, which seems alright to me.
                    if (!player.dbLocationName.Contains("dungeon_"))
                    {
                        malethief.dbLocationName   = target.dbLocationName;
                        femalethief.dbLocationName = target.dbLocationName;

                        // take money from victim and give some to the thieves with an uneven split.  Multiple the thieves' gain by 3
                        // because only about a third of Arpeyis are actually collected from a completed inanimation
                        target.Money       = Math.Floor(target.Money * .90M);
                        malethief.Money   += Math.Floor(target.Money * .025M);
                        femalethief.Money += Math.Floor(target.Money * .075M);

                        playerRepo.SavePlayer(target);
                        playerRepo.SavePlayer(malethief);
                        playerRepo.SavePlayer(femalethief);

                        AttackProcedures.Attack(femalethief, target, StunSpellSourceId);
                        AIProcedures.DealBossDamage(femalethief, target, false, 1);

                        var message         = malethief.GetFullName() + " and " + femalethief.GetFullName() + " the Seekshadow rat thieves suddenly appear in front of you!  In the blink of an eye they've swept you off your feet and have expertly swiped " + Math.Floor(target.Money * .10M) + " of your Arpeyjis.";
                        var locationMessage = "<b>" + malethief.GetFullName() + " and " + femalethief.GetFullName() + " robbed " + target.GetFullName() + " here.</b>";
                        PlayerLogProcedures.AddPlayerLog(target.Id, message, true);
                        LocationLogProcedures.AddLocationLog(malethief.dbLocationName, locationMessage);

                        maleAI.Var1++;

                        if (maleAI.Var1 >= 20)
                        {
                            maleAI.Var1 = 0;
                        }
                        aiRepo.SaveAIDirective(maleAI);
                    }
                    else
                    {
                        // If the target is in the dungeon, move it on to the next target.
                        maleAI.Var1++;

                        if (maleAI.Var1 >= 20)
                        {
                            maleAI.Var1 = 0;
                        }
                        aiRepo.SaveAIDirective(maleAI);
                    }
                }
                catch
                {
                    maleAI.Var1 = 0;
                }
            }
            #endregion

            #region veangance mode
            // one of the thieves has been taken down.  The other will try and steal their inanimate friend back!
            if (malethief.Mobility != PvPStatics.MobilityFull || femalethief.Mobility != PvPStatics.MobilityFull)
            {
                Player attackingThief;
                Player itemThief;

                if (malethief.Mobility == PvPStatics.MobilityFull && femalethief.Mobility != PvPStatics.MobilityFull)
                {
                    attackingThief = malethief;
                    itemThief      = femalethief;
                }
                else
                {
                    attackingThief = femalethief;
                    itemThief      = malethief;
                }

                var victimThiefItem = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer {
                    PlayerId = itemThief.Id
                });

                // the transformed thief is owned by someone, try and get it back!
                if (victimThiefItem.Owner != null)
                {
                    var target = playerRepo.Players.FirstOrDefault(p => p.Id == victimThiefItem.Owner.Id);

                    if (target.BotId == AIStatics.MaleRatBotId || target.BotId == AIStatics.FemaleRatBotId)
                    {
                        // do nothing, the thief already has the item... equip it if not
                        if (!victimThiefItem.IsEquipped)
                        {
                            ItemProcedures.EquipItem(victimThiefItem.Id, true);
                        }
                        var newlocation = LocationsStatics.GetRandomLocation_NoStreets();
                        AIProcedures.MoveTo(attackingThief, newlocation, 100000);
                        attackingThief.dbLocationName = newlocation;
                        playerRepo.SavePlayer(attackingThief);
                        var buffs = ItemProcedures.GetPlayerBuffs(attackingThief);

                        if (attackingThief.Health < attackingThief.Health / 10)
                        {
                            DomainRegistry.Repository.Execute(new Cleanse {
                                PlayerId = attackingThief.Id, Buffs = buffs, NoValidate = true
                            });
                        }

                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = attackingThief.Id, Buffs = buffs, NoValidate = true
                        });
                    }

                    // Lindella, steal from her right away
                    else if (target.BotId == AIStatics.LindellaBotId)
                    {
                        ItemProcedures.GiveItemToPlayer(victimThiefItem.Id, attackingThief.Id);
                        LocationLogProcedures.AddLocationLog(target.dbLocationName, "<b>" + attackingThief.GetFullName() + " stole " + victimThiefItem.FormerPlayer.FullName + " the " + victimThiefItem.ItemSource.FriendlyName + " from Lindella.</b>");
                    }

                    // target is a human and they are not offline
                    else if (target != null && target.Mobility == PvPStatics.MobilityFull && !PlayerProcedures.PlayerIsOffline(target) && victimThiefItem.SoulboundToPlayer == null)
                    {
                        attackingThief.dbLocationName = target.dbLocationName;
                        playerRepo.SavePlayer(attackingThief);
                        AttackProcedures.Attack(attackingThief, target, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(attackingThief, target, PvPStatics.Spell_WeakenId);
                        AttackProcedures.Attack(attackingThief, target, GoldenTrophySpellSourceId);
                        AttackProcedures.Attack(attackingThief, target, GoldenTrophySpellSourceId);
                        AIProcedures.DealBossDamage(attackingThief, target, false, 4);
                        target = playerRepo.Players.FirstOrDefault(p => p.Id == victimThiefItem.Owner.Id && p.BotId != AIStatics.MaleRatBotId && p.BotId != AIStatics.FemaleRatBotId);

                        // if we have managed to turn the target, take back the victim-item
                        if (target.Mobility != PvPStatics.MobilityFull)
                        {
                            ItemProcedures.GiveItemToPlayer(victimThiefItem.Id, attackingThief.Id);
                            LocationLogProcedures.AddLocationLog(target.dbLocationName, "<b>" + attackingThief.GetFullName() + " recovered " + victimThiefItem.FormerPlayer.FullName + " the " + victimThiefItem.ItemSource.FriendlyName + ".</b>");
                        }
                    }

                    // target is a human and they are offline... just go and camp out there.
                    else if (target != null && PlayerProcedures.PlayerIsOffline(target))
                    {
                        attackingThief.dbLocationName = target.dbLocationName;
                        playerRepo.SavePlayer(attackingThief);
                    }
                }

                // item is on the ground, just go and pick it up.
                else
                {
                    attackingThief.dbLocationName = victimThiefItem.dbLocationName;
                    playerRepo.SavePlayer(attackingThief);
                    ItemProcedures.GiveItemToPlayer(victimThiefItem.Id, attackingThief.Id);
                    LocationLogProcedures.AddLocationLog(attackingThief.dbLocationName, "<b>" + attackingThief.GetFullName() + " recovered " + victimThiefItem.FormerPlayer.FullName + " the " + victimThiefItem.ItemSource.FriendlyName + ".</b>");
                }
            }
            #endregion
        }
Пример #12
0
        public static void Run(int turnNumber, MinibossData data)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var miniboss =
                playerRepo.Players.FirstOrDefault(p => p.BotId == data.BotId && p.Mobility == PvPStatics.MobilityFull);

            // spawn a new boss if last is null
            if (miniboss == null && rand.NextDouble() < ChanceToRespawn)
            {
                var spawnLocation = LocationsStatics.GetRandomLocation_InRegion(data.Region);

                var cmd = new CreatePlayer
                {
                    FirstName    = data.Title,
                    LastName     = NameService.GetRandomLastName(),
                    Location     = spawnLocation,
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = data.FormSourceId,
                    Money        = 2000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = GetLevel(turnNumber),
                    BotId        = data.BotId
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var minibossEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                minibossEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(minibossEF));
                playerRepo.SavePlayer(minibossEF);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = data.RuneIdToGive, PlayerId = minibossEF.Id
                    });
                }
            }

            if (miniboss != null && miniboss.Mobility == PvPStatics.MobilityFull)
            {
                // move to a randomn location in this region
                var nextLocation       = LocationsStatics.GetRandomLocation_InRegion(data.Region);
                var actualNextLocation = AIProcedures.MoveTo(miniboss, nextLocation, 11);
                miniboss.dbLocationName = actualNextLocation;
                miniboss.Mana           = miniboss.MaxMana;
                playerRepo.SavePlayer(miniboss);
                var playersHere = GetEligibleTargetsAtLocation(actualNextLocation);
                foreach (var target in playersHere)
                {
                    var(complete, _) = AttackProcedures.Attack(miniboss, target, ChooseSpell(miniboss, turnNumber, data.Spells));

                    if (complete)
                    {
                        AIProcedures.EquipDefeatedPlayer(miniboss, target);
                    }
                }
            }
        }
        public static string TeleportToHostileNPC(Player player, bool attack, Random rand = null)
        {
            var targetFormSourceId = -1;
            var minLevel           = 4;

            IPlayerRepository playerRepo = new EFPlayerRepository();

            // Bosses
            var hostiles = playerRepo.Players.Where(p => p.Mobility == PvPStatics.MobilityFull && (
                                                        p.BotId == AIStatics.BimboBossBotId ||
                                                        p.BotId == AIStatics.DonnaBotId ||
                                                        p.BotId == AIStatics.FaebossBotId ||
                                                        p.BotId == AIStatics.MotorcycleGangLeaderBotId ||
                                                        p.BotId == AIStatics.MouseBimboBotId ||
                                                        p.BotId == AIStatics.MouseNerdBotId ||
                                                        p.BotId == AIStatics.FemaleRatBotId ||
                                                        p.BotId == AIStatics.MaleRatBotId ||
                                                        p.BotId == AIStatics.ValentineBotId)).ToList();

            // Minibosses
            if (hostiles == null || hostiles.IsEmpty())
            {
                hostiles = playerRepo.Players.Where(p => p.Mobility == PvPStatics.MobilityFull && (
                                                        p.BotId == AIStatics.MinibossPlushAngelId ||
                                                        p.BotId == AIStatics.MinibossArchangelId ||
                                                        p.BotId == AIStatics.MinibossArchdemonId ||
                                                        p.BotId == AIStatics.MinibossExchangeProfessorId ||
                                                        p.BotId == AIStatics.MinibossFiendishFarmhandId ||
                                                        p.BotId == AIStatics.MinibossGroundskeeperId ||
                                                        p.BotId == AIStatics.MinibossLazyLifeguardId ||
                                                        p.BotId == AIStatics.MinibossPopGoddessId ||
                                                        p.BotId == AIStatics.MinibossPossessedMaidId ||
                                                        p.BotId == AIStatics.MinibossSeamstressId ||
                                                        p.BotId == AIStatics.MinibossSororityMotherId)).ToList();
            }

            rand = rand ?? new Random();
            Player npcPlayer = null;

            if (hostiles != null && hostiles.Any())
            {
                npcPlayer = hostiles[rand.Next(hostiles.Count())];
            }

            // Psychopaths
            if (npcPlayer == null)
            {
                npcPlayer = playerRepo.Players.Where(p => p.Mobility == PvPStatics.MobilityFull &&
                                                     p.BotId == AIStatics.PsychopathBotId &&
                                                     p.Level <= player.Level)
                            .OrderByDescending(p => p.Level).FirstOrDefault();
                minLevel = 1;
            }

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

            // Turn into form needed to attack
            if (npcPlayer.BotId == AIStatics.MouseBimboBotId)
            {
                targetFormSourceId = BossProcedures_Sisters.NerdSpellFormSourceId;
            }
            else if (npcPlayer.BotId == AIStatics.MouseNerdBotId)
            {
                targetFormSourceId = BossProcedures_Sisters.BimboSpellFormSourceId;
            }

            if (targetFormSourceId != -1)
            {
                CharacterPrankProcedures.TryAnimateTransform(player, targetFormSourceId);
            }

            // Move to same tile as NPC
            if (!Teleport(player, npcPlayer.dbLocationName, rand.Next(2) == 0))
            {
                return(null);
            }

            var message = "The shop suddenly seems to connect with some evil force.  A vortex opens and you are pulled in towards the source of the magic!";

            if (attack && player.Level >= minLevel)
            {
                var spells = SkillProcedures.AvailableSkills(player, npcPlayer, true);
                if (spells != null && spells.Any())
                {
                    var spellList = spells.ToArray();
                    var spell     = spellList[rand.Next(spellList.Count())];

                    // Note we do not apply the full gamut of preconditions of a manual attack present in the controller
                    var attackMessage = AttackProcedures.AttackSequence(player, npcPlayer, spell);
                    message = $"{message}<br />{attackMessage}";
                }
            }

            return(message);
        }
Пример #14
0
        public void Configuration(IAppBuilder app)
        {
            var container       = new Container();
            var httpConfig      = new HttpConfiguration();
            var signalrResolver = new SimpleInjectorSignalRDependencyResolver(container);

            container.RegisterContainer(httpConfig, app.GetDataProtectionProvider);

            // cross owin and simple injector for OnValidateIdentity
            app.CreatePerOwinContext(container.GetInstance <ApplicationUserManager>);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, User>(
                        validateInterval: TimeSpan.FromMinutes(5),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

            app.MapScopableHubConnection(async(request, connectionId, next) =>
            {
                using (AsyncScopedLifestyle.BeginScope(container))
                {
                    if (container.GetInstance <IHubRequestAccessor>() is HubRequestAccessor hubRequestAccessor)
                    {
                        hubRequestAccessor.Request = request;
                    }

                    if (container.GetInstance <IHubConnectionIdAccessor>() is HubConnectionIdAccessor hubConnectionIdAccessor)
                    {
                        hubConnectionIdAccessor.ConnectionId = connectionId;
                    }

                    await next();
                }
            },
                                         resolver: signalrResolver);

            app.Use(async(context, next) =>
            {
                // check if there is a HttpContext for WebRequestLifestyle to store its scope
                if (HttpContext.Current != null)
                {
                    // capture the owin context for any service dependant on it and store it in the async scoped container
                    // this will use WebRequestLifestyle's cache
                    if (container.GetInstance <IOwinContextAccessor>() is OwinContextAccessor webrequestCallContextOwinContextAccessor)
                    {
                        webrequestCallContextOwinContextAccessor.CurrentContext = context;
                    }
                }

                using (AsyncScopedLifestyle.BeginScope(container))
                {
                    // capture the owin context for any service dependant on it and store it in the async scoped container
                    // this will use AsyncScopedLifestyle's cache
                    if (container.GetInstance <IOwinContextAccessor>() is OwinContextAccessor asyncCallContextOwinContextAccessor)
                    {
                        asyncCallContextOwinContextAccessor.CurrentContext = context;
                    }

                    await next();
                }
            });

            app.UseWebApi(httpConfig);

            AttackProcedures.LoadCovenantOwnersIntoRAM();
            DungeonProcedures.GenerateDungeon();

            // set chaos mode
            IPvPWorldStatRepository repo = new EFPvPWorldStatRepository();
            var data = repo.PvPWorldStats.FirstOrDefault();

            PvPStatics.ChaosMode     = data != null ? data.ChaosMode : false;
            PvPStatics.RoundDuration = data != null ? data.RoundDuration : 5000;

            TurnTimesStatics.ActiveConfiguration = data != null && TurnTimesStatics.IsValidConfiguration(data.TurnTimeConfiguration) ? data.TurnTimeConfiguration : TurnTimesStatics.FiveMinuteTurns;

            PvPStatics.AlphaRound = DomainRegistry.Repository.FindSingle(new GetWorld()).RoundNumber ?? PvPStatics.AlphaRound;

            if (data != null)
            {
                JokeShopProcedures.SetJokeShopActive(data.JokeShop);
            }
        }
Пример #15
0
        public static void RunSistersAction()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var nerdBoss  = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.MouseNerdBotId);
            var bimboBoss = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.MouseBimboBotId);

            // check to see if a sister has been TFed and the event should end
            if (nerdBoss == null || nerdBoss.FormSourceId != NerdBossFormSourceId || bimboBoss == null || bimboBoss.FormSourceId != BimboBossFormSourceId)
            {
                EndEvent();
            }
            else
            {
                // get all of the players in the room by nerd
                var playersByNerd = PlayerProcedures.GetPlayersAtLocation(nerdBoss.dbLocationName).ToList();
                playersByNerd = playersByNerd.Where(p => p.Mobility == PvPStatics.MobilityFull &&
                                                    !PlayerProcedures.PlayerIsOffline(p) &&
                                                    p.BotId == AIStatics.ActivePlayerBotId &&
                                                    p.Id != nerdBoss.Id &&
                                                    p.FormSourceId != NerdSpellFormSourceId &&
                                                    p.InDuel <= 0 &&
                                                    p.InQuest <= 0).ToList();


                // get all of the players in the room by bimbo
                var playersByBimbo = PlayerProcedures.GetPlayersAtLocation(bimboBoss.dbLocationName).ToList();
                playersByBimbo = playersByBimbo.Where(p => p.Mobility == PvPStatics.MobilityFull &&
                                                      !PlayerProcedures.PlayerIsOffline(p) &&
                                                      p.BotId == AIStatics.ActivePlayerBotId &&
                                                      p.Id != bimboBoss.Id &&
                                                      p.FormSourceId != BimboSpellFormSourceId &&
                                                      p.InDuel <= 0 &&
                                                      p.InQuest <= 0).ToList();


                if (nerdBoss.Mana < nerdBoss.MaxMana / 2)
                {
                    var nerdBuffs = ItemProcedures.GetPlayerBuffs(nerdBoss);

                    for (var i = 0; i < 3; i++)
                    {
                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = nerdBoss.Id, Buffs = nerdBuffs, NoValidate = true
                        });
                    }
                }

                foreach (var p in playersByNerd)
                {
                    AttackProcedures.Attack(nerdBoss, p, NerdSpellSourceId);
                    AttackProcedures.Attack(nerdBoss, p, NerdSpellSourceId);
                    AttackProcedures.Attack(nerdBoss, p, NerdSpellSourceId);
                    AIProcedures.DealBossDamage(nerdBoss, p, false, 3);
                }


                if (bimboBoss.Mana < bimboBoss.MaxMana / 2)
                {
                    var bimboBuffs = ItemProcedures.GetPlayerBuffs(bimboBoss);

                    for (var i = 0; i < 3; i++)
                    {
                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = bimboBoss.Id, Buffs = bimboBuffs, NoValidate = true
                        });
                    }
                }

                foreach (var p in playersByBimbo)
                {
                    AttackProcedures.Attack(bimboBoss, p, BimboSpellSourceId);
                    AttackProcedures.Attack(bimboBoss, p, BimboSpellSourceId);
                    AttackProcedures.Attack(bimboBoss, p, BimboSpellSourceId);
                    AIProcedures.DealBossDamage(bimboBoss, p, false, 3);
                }
            }
        }
Пример #16
0
        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);
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Perform Narcissa's regular actions when a new turn has started.  If Narcissa has no aggroed target, she seeks to transform random people into
        /// certain animate forms.  If she has aggro, she will attempt to chase them and cast a pet spell on them.  If she can't catch up, she'll cast the animate
        /// spells in the area instead and resume pursuit next turn.
        /// </summary>
        public static void RunTurnLogic()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var faeboss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FaebossBotId);

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

            // have Narcissa periodically drop all of her pets/belongings so she doesn't get OP with them
            if (PvPWorldStatProcedures.GetWorldTurnNumber() % 12 == 0)
            {
                DomainRegistry.Repository.Execute(new DropAllItems {
                    PlayerId = faeboss.Id, IgnoreRunes = true
                });
            }

            // have Narcissa meditate to get her mana back up
            faeboss.Mana = faeboss.MaxMana;


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

            // no target, go out and hit some random people with animate spells
            if (!HasValidTarget(directive))
            {
                ResetTarget(directive);
                var newTargetLocation = GetLocationWithMostEligibleTargets();
                var newActualLocation = AIProcedures.MoveTo(faeboss, newTargetLocation, GetRandomChaseDistance());
                faeboss.dbLocationName = newActualLocation;
                playerRepo.SavePlayer(faeboss);

                CastAnimateSpellsAtLocation(faeboss);
            }

            // Narcissa has a valid target, go for them
            else
            {
                var target            = PlayerProcedures.GetPlayer((int)directive.Var1);
                var newTargetLocation = target.dbLocationName;
                var newActualLocation = AIProcedures.MoveTo(faeboss, newTargetLocation, GetRandomChaseDistance());
                faeboss.dbLocationName = newActualLocation;
                playerRepo.SavePlayer(faeboss);

                if (faeboss.dbLocationName == target.dbLocationName)
                {
                    var spell = ChooseSpell(PvPWorldStatProcedures.GetWorldTurnNumber(), PvPStatics.MobilityPet);

                    for (var i = 0; i < 4; i++)
                    {
                        AttackProcedures.Attack(faeboss, target, spell);
                    }
                }
                else
                {
                    CastAnimateSpellsAtLocation(faeboss);
                }
            }
        }
        public static void RunValentineActions()
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var valentine = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.ValentineBotId);

            // if valentine is not in the right place have him move to the other location
            var locationToBe = GetStanceLocation();

            if (valentine.dbLocationName != locationToBe)
            {
                AIProcedures.MoveTo(valentine, locationToBe, 100000);
                valentine.dbLocationName = locationToBe;
                playerRepo.SavePlayer(valentine);
            }

            // get all of the players in the room
            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.InDuel <= 0 &&
                                            p.InQuest <= 0).ToList();

            var turnNo = PvPWorldStatProcedures.GetWorldTurnNumber();

            if (valentine.Mana < valentine.MaxMana / 3)
            {
                var valentineBuffs = ItemProcedures.GetPlayerBuffs(valentine);
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = valentine.Id, Buffs = valentineBuffs, NoValidate = true
                });
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = valentine.Id, Buffs = valentineBuffs, NoValidate = true
                });
            }

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

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

            // have Valentine equip his two strongest swords
            IItemRepository    itemRepo        = new EFItemRepository();
            IEnumerable <Item> valentineSwords = itemRepo.Items.Where(i => i.OwnerId == valentine.Id && i.ItemSourceId != QueensPantiesItemSourceId).OrderByDescending(i => i.Level);
            var swordsToSave = new List <Item>();

            var counter = 1;

            foreach (var sword in valentineSwords)
            {
                if (!sword.IsEquipped && counter < 3)
                {
                    sword.IsEquipped = true;
                    swordsToSave.Add(sword);
                }
                else if (sword.IsEquipped && counter >= 3)
                {
                    sword.IsEquipped = false;
                    swordsToSave.Add(sword);
                }
                counter++;
            }

            foreach (var sword in swordsToSave)
            {
                itemRepo.SaveItem(sword);
            }
        }
        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);
                    }
                }
            }
        }
Пример #20
0
        public static void CounterAttack(Player attacker)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var malethief   = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MaleRatBotId);
            var femalethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FemaleRatBotId);
            var rand        = new Random(Guid.NewGuid().GetHashCode());

            // both thieves are full, dont' attack too hard
            if (malethief.Mobility == PvPStatics.MobilityFull && femalethief.Mobility == PvPStatics.MobilityFull)
            {
                if (malethief.Mobility == PvPStatics.MobilityFull)
                {
                    AttackProcedures.Attack(malethief, attacker, PvPStatics.Spell_WeakenId);
                    AIProcedures.DealBossDamage(malethief, attacker, true, 1);
                    malethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.MaleRatBotId);
                }

                if (femalethief.Mobility == PvPStatics.MobilityFull)
                {
                    AttackProcedures.Attack(femalethief, attacker, GoldenTrophySpellSourceId);
                    AttackProcedures.Attack(femalethief, attacker, GoldenTrophySpellSourceId);
                    AIProcedures.DealBossDamage(femalethief, attacker, true, 2);
                    femalethief = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.FemaleRatBotId);
                }


                var roll = rand.NextDouble();

                // random chance of moving to a new random location
                if (roll < .166)
                {
                    AttackProcedures.Attack(femalethief, attacker, StunSpellSourceId);
                    AIProcedures.DealBossDamage(femalethief, attacker, false, 1);
                    var locationMessage = "<b>" + malethief.GetFullName() + " and " + femalethief.GetFullName() + " ran off in an unknown direction.</b>";
                    LocationLogProcedures.AddLocationLog(femalethief.dbLocationName, locationMessage);
                    var newlocation = LocationsStatics.GetRandomLocation_NoStreets();
                    malethief.dbLocationName   = newlocation;
                    femalethief.dbLocationName = newlocation;
                    playerRepo.SavePlayer(malethief);
                    playerRepo.SavePlayer(femalethief);
                }
            }

            // one thief is defeated, the other goes berserk
            else
            {
                var roll = rand.NextDouble() * 3;
                if (malethief.Mobility == PvPStatics.MobilityFull)
                {
                    for (var i = 0; i < roll; i++)
                    {
                        AttackProcedures.Attack(malethief, attacker, GoldenTrophySpellSourceId);
                        AIProcedures.DealBossDamage(malethief, attacker, false, 2);
                    }
                }
                else if (femalethief.Mobility == PvPStatics.MobilityFull)
                {
                    for (var i = 0; i < roll; i++)
                    {
                        AttackProcedures.Attack(femalethief, attacker, GoldenTrophySpellSourceId);
                        AIProcedures.DealBossDamage(femalethief, attacker, false, 2);
                    }
                }
            }
        }
Пример #21
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);
            }
        }
Пример #22
0
        public static void RunActions(int turnNumber)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var bimboBoss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.BimboBossBotId);

            // move her toward the location with the most eligible targets
            if (bimboBoss == null || bimboBoss.Mobility != PvPStatics.MobilityFull)
            {
                EndEvent();
                return;
            }

            var targetLocation = GetLocationWithMostEligibleTargets();
            var newlocation    = AIProcedures.MoveTo(bimboBoss, targetLocation, 13);

            bimboBoss.dbLocationName = newlocation;

            playerRepo.SavePlayer(bimboBoss);
            bimboBoss = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.BimboBossBotId);
            var bimboBossBuffs = ItemProcedures.GetPlayerBuffs(bimboBoss);

            // Get mana back up
            if (bimboBoss.Mana < bimboBoss.MaxMana / 4)
            {
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
            }
            else if (bimboBoss.Mana < bimboBoss.MaxMana / 3)
            {
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
            }
            else if (bimboBoss.Mana < bimboBoss.MaxMana / 2)
            {
                DomainRegistry.Repository.Execute(new Meditate {
                    PlayerId = bimboBoss.Id, Buffs = bimboBossBuffs, NoValidate = true
                });
            }

            var rand = new Random(Guid.NewGuid().GetHashCode());

            // attack all eligible targets here, even if it's not her final destination
            var playersHere = GetEligibleTargetsInLocation(newlocation, bimboBoss);

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


                // otherwise run the regular trasformation
                else if (p.FormSourceId != RegularBimboFormSourceId)
                {
                    AttackProcedures.Attack(bimboBoss, p, RegularTFSpellSourceId);
                    AIProcedures.DealBossDamage(bimboBoss, p, false, 1);
                }
            }

            // have a random chance that infected players spontaneously transform
            IEffectRepository effectRepo = new EFEffectRepository();
            var ownerIds = effectRepo.Effects.Where(e => e.EffectSourceId == KissEffectSourceId).Select(e => e.OwnerId).ToList();

            foreach (var effectId in ownerIds)
            {
                var infectee = playerRepo.Players.FirstOrDefault(p => p.Id == effectId);

                // if the infectee is no longer animate or is another boss, skip them
                if (infectee.Mobility != PvPStatics.MobilityFull || infectee.BotId < AIStatics.PsychopathBotId)
                {
                    continue;
                }

                var roll = rand.NextDouble();

                // random chance of spontaneously transforming
                if (infectee.FormSourceId != RegularBimboFormSourceId && !PlayerProcedures.PlayerIsOffline(infectee))
                {
                    if (roll < .16 && infectee.InDuel <= 0 && infectee.InQuest <= 0)
                    {
                        DomainRegistry.Repository.Execute(new ChangeForm
                        {
                            PlayerId     = infectee.Id,
                            FormSourceId = RegularBimboFormSourceId
                        });

                        DomainRegistry.Repository.Execute(new ReadjustMaxes
                        {
                            playerId = infectee.Id,
                            buffs    = ItemProcedures.GetPlayerBuffs(infectee)
                        });

                        infectee = playerRepo.Players.FirstOrDefault(p => p.Id == effectId);

                        var message       = "You gasp, your body shifting as the virus infecting you overwhelms your biological and arcane defenses.  Before long you find that your body has been transformed into that of one of the many bimbonic plague victims and you can't help but succumb to the urges to spread your infection--no, your gift!--on to the rest of mankind.";
                        var loclogMessage = "<b style='color: red'>" + infectee.GetFullName() + " succumbed to the bimbonic virus, spontaneously transforming into one of Lady Lovebringer's bimbos.</b>";

                        PlayerLogProcedures.AddPlayerLog(infectee.Id, message, true);
                        LocationLogProcedures.AddLocationLog(infectee.dbLocationName, loclogMessage);
                    }
                }

                // spread the kiss so long as the player is not offline
                if (infectee.FormSourceId == RegularBimboFormSourceId && !PlayerProcedures.PlayerIsOffline(infectee))
                {
                    // back up the last action timestamp since we don't want these attacks to count against their offline timer
                    var lastActionBackup = infectee.LastActionTimestamp;

                    var eligibleTargets  = GetEligibleTargetsInLocation(infectee.dbLocationName, infectee);
                    var attacksMadeCount = 0;

                    foreach (var p in eligibleTargets)
                    {
                        if (!EffectProcedures.PlayerHasEffect(p, KissEffectSourceId) && !EffectProcedures.PlayerHasEffect(p, CureEffectSourceId) && attacksMadeCount < 3)
                        {
                            attacksMadeCount++;
                            AttackProcedures.Attack(infectee, p, KissSkillSourceId);
                        }
                        else if (attacksMadeCount < 3)
                        {
                            AttackProcedures.Attack(infectee, p, RegularTFSpellSourceId);
                            attacksMadeCount++;
                        }
                    }

                    // if there were any attacked players, restore the old last action timestamp and make sure AP and mana has not gone into negative
                    if (attacksMadeCount > 0)
                    {
                        infectee = playerRepo.Players.FirstOrDefault(p => p.Id == effectId);
                        infectee.LastActionTimestamp = lastActionBackup;

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

                        if (infectee.Mana < 0)
                        {
                            infectee.Mana = 0;
                        }

                        playerRepo.SavePlayer(infectee);
                    }
                }
            }


            // every 5 turns heal the boss based on how many infected bots there are
            if (ShouldHeal(bimboBoss, turnNumber))
            {
                var activeCurses = effectRepo.Effects.Count(eff => eff.EffectSourceId == KissEffectSourceId) * 5;
                activeCurses      = activeCurses > 130 ? 130 : activeCurses;
                bimboBoss.Health += activeCurses;
                playerRepo.SavePlayer(bimboBoss);
                var message = "<b>" + bimboBoss.GetFullName() + " draws energy from her bimbo horde, regenerating her own willpower by " + activeCurses + ".</b>";
                LocationLogProcedures.AddLocationLog(newlocation, message);
            }

            // drop a cure
            DropCure(turnNumber);
        }