Exemplo n.º 1
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}");
        }
        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);
        }