public static void SpawnBartender()
        {
            var bartender = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.DonnaBotId
            });

            if (bartender == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = "Rusty",
                    LastName     = "Steamstein the Automaton Bartender",
                    Location     = "tavern_counter",
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = BartenderFormId,
                    Money        = 0,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 15,
                    BotId        = AIStatics.BartenderBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                IPlayerRepository playerRepo = new EFPlayerRepository();
                var newBartender             = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                newBartender.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newBartender));
                playerRepo.SavePlayer(newBartender);
            }
        }
Ejemplo n.º 2
0
        public virtual ActionResult DeMeditateVictim(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__MeditateFormSourceId);

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

            var buffs  = ItemProcedures.GetPlayerBuffs(victim);
            var result = PlayerProcedures.DeMeditate(victim, me, buffs);

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


            TempData["Result"] = "You force " + victim.GetFullName() + " to meditate while filling their mind with nonsense instead of relaxation, lowering their mana instead of increasing it!";
            StatsProcedures.AddStat(me.MembershipId, StatsProcedures.Stat__MindControlCommandsIssued, 1);

            return(RedirectToAction(MVC.PvP.Play()));
        }
        public static void SpawnPetMerchant()
        {
            var petMerchant = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.WuffieBotId
            });

            if (petMerchant == null)
            {
                var cmd = new CreatePlayer
                {
                    BotId        = AIStatics.WuffieBotId,
                    Level        = 5,
                    FirstName    = "Wüffie",
                    LastName     = "the Soul Pet Vendor",
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    Mobility     = PvPStatics.MobilityFull,
                    Money        = 1000,
                    FormSourceId = WuffieFormId,
                    Location     = "270_west_9th_ave", // Lindella starts her rounds here
                    Gender       = PvPStatics.GenderFemale,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo    = new EFPlayerRepository();
                var petMerchantEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                petMerchantEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(petMerchantEF));
                playerRepo.SavePlayer(petMerchantEF);
            }
        }
Ejemplo n.º 4
0
        public static void SpawnLoremaster()
        {
            var loremaster = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.LoremasterBotId
            });

            if (loremaster == null)
            {
                var cmd = new CreatePlayer
                {
                    BotId        = AIStatics.LoremasterBotId,
                    Level        = 5,
                    FirstName    = FirstName,
                    LastName     = LastName,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    Mobility     = PvPStatics.MobilityFull,
                    Money        = 1000,
                    FormSourceId = LoremasterFormId,
                    Location     = "bookstore_back",
                    Gender       = PvPStatics.GenderMale,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo   = new EFPlayerRepository();
                var lorekeeperEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                lorekeeperEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(lorekeeperEF));
                playerRepo.SavePlayer(lorekeeperEF);
            }
        }
        public static void SpawnLindella()
        {
            var merchant = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.LindellaBotId
            });

            if (merchant == null)
            {
                var cmd = new CreatePlayer
                {
                    BotId        = AIStatics.LindellaBotId,
                    Level        = 5,
                    FirstName    = "Lindella",
                    LastName     = "the Soul Vendor",
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    Mobility     = PvPStatics.MobilityFull,
                    Money        = 1000,
                    FormSourceId = LindellaFormId,
                    Location     = "270_west_9th_ave", // Lindella starts her rounds here
                    Gender       = PvPStatics.GenderFemale,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                IPlayerRepository playerRepo = new EFPlayerRepository();
                var newMerchant = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                newMerchant.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newMerchant));
                playerRepo.SavePlayer(newMerchant);

                AIDirectiveProcedures.GetAIDirective(id);
                AIDirectiveProcedures.SetAIDirective_MoveTo(id, "street_15th_south");
            }
        }
Ejemplo n.º 6
0
        public virtual ActionResult Quest()
        {
            IQuestRepository repo = new EFQuestRepository();

            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            var unopenedMessageCount = DomainRegistry.Repository.FindSingle(new GetUnreadMessageCountByPlayer {
                OwnerId = me.Id
            });
            var openedUnreadMessageCount = DomainRegistry.Repository.FindSingle(new GetReadAndMarkedAsUnreadMessageCountByPlayer {
                OwnerId = me.Id
            });

            var output = new QuestPlayPageViewModel();

            output.Player               = PlayerProcedures.GetPlayerFormViewModel(me.Id);
            output.QuestStart           = QuestProcedures.GetQuest(me.InQuest);
            output.QuestState           = QuestProcedures.GetQuestState(me.InQuestState);
            output.QuestConnections     = QuestProcedures.GetChildQuestConnections(me.InQuestState);
            output.BuffBox              = ItemProcedures.GetPlayerBuffs(me);
            output.QuestPlayerVariables = QuestProcedures.GetAllQuestPlayerVariablesFromQuest(output.QuestStart.Id, me.Id);
            output.HasNewMessages       = unopenedMessageCount != 0;
            output.UnreadMessageCount   = unopenedMessageCount + openedUnreadMessageCount;

            ViewBag.ErrorMessage    = TempData["Error"];
            ViewBag.SubErrorMessage = TempData["SubError"];
            ViewBag.Result          = TempData["Result"];

            output.SetConnectionText((string)TempData["ConnectionText"]);

            return(PartialView(MVC.Quest.Views.Quest, output));
        }
Ejemplo n.º 7
0
        public static void SpawnBimboBoss()
        {
            var bimboBoss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.BimboBossBotId
            });

            if (bimboBoss == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = BossFirstName,
                    LastName     = BossLastName,
                    Location     = "stripclub_bar_seats",
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = BimboBossFormSourceId,
                    Money        = 2500,
                    Level        = 15,
                    BotId        = AIStatics.BimboBossBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

                var playerRepo = new EFPlayerRepository();
                var bimboEF    = playerRepo.Players.FirstOrDefault(p => p.Id == id);

                bimboEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(bimboEF));

                playerRepo.SavePlayer(bimboEF);


                // set up her AI directive so it is not deleted
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var directive = new AIDirective
                {
                    OwnerId        = id,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    DoNotRecycleMe = true,
                };

                aiRepo.SaveAIDirective(directive);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.BIMBO_RUNE, PlayerId = bimboEF.Id
                    });
                }
            }
        }
Ejemplo n.º 8
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);
                }
            }
        }
        public static void SpawnFae()
        {
            var fae = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.JewdewfaeBotId
            });

            if (fae == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = FirstName,
                    LastName     = LastName,
                    Location     = "apartment_dog_park",
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = FaeFormId,
                    Money        = 1000,
                    Level        = 7,
                    BotId        = AIStatics.JewdewfaeBotId
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                // set up her AI directive so it is not deleted
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var directive = new AIDirective
                {
                    OwnerId        = id,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = 0,
                    DoNotRecycleMe = true,
                    sVar1          = ";", // this is used to keep track of which players have interacted with her by appending their id to this string
                    sVar2          = "",  // this is used to keep track of which locations Jewdewfae has been in during the past cycle
                    Var1           = 0,   // this keeps track of how many people she has played with in the current location
                    Var2           = 0    // this stores the turn number of Jewdewfae's last move
                };

                aiRepo.SaveAIDirective(directive);
            }
        }
Ejemplo n.º 10
0
        private static void PerformAnimateTransformation(Player victim, Player attacker, DbStaticForm targetForm, LogBox output)
        {
            var playerRepo = new EFPlayerRepository();
            var dbVictim   = playerRepo.Players.FirstOrDefault(p => p.Id == victim.Id);

            SkillProcedures.UpdateFormSpecificSkillsToPlayer(dbVictim, targetForm.Id);
            DomainRegistry.Repository.Execute(new ChangeForm
            {
                PlayerId     = dbVictim.Id,
                FormSourceId = targetForm.Id
            });

            // wipe out half of the target's mana
            dbVictim.Mana -= dbVictim.MaxMana / 2;
            if (dbVictim.Mana < 0)
            {
                dbVictim.Mana = 0;
            }

            // Remove any Self Restore entires.
            RemoveSelfRestore(dbVictim);

            var targetbuffs = ItemProcedures.GetPlayerBuffs(dbVictim);

            dbVictim = PlayerProcedures.ReadjustMaxes(dbVictim, targetbuffs);


            // take away some of the victim's XP based on the their level
            // target.XP += -2.5M * target.Level;

            playerRepo.SavePlayer(dbVictim);

            output.LocationLog += $"<br><b>{dbVictim.GetFullName()} was completely transformed into a {targetForm.FriendlyName} here.</b>";
            output.AttackerLog += $"<br><b>You fully transformed {dbVictim.GetFullName()} into a {targetForm.FriendlyName}</b>!";
            output.VictimLog   += $"<br><b>You have been fully transformed into a {targetForm.FriendlyName}!</b>";

            // Let the target know they are best friends with the angel plush.
            if (attacker.BotId == AIStatics.MinibossPlushAngelId)
            {
                output.VictimLog += $"<br><br><b>{attacker.GetFullName()}</b> was happy to make you into a new friend!<br>";
            }

            TFEnergyProcedures.DeleteAllPlayerTFEnergiesOfFormSourceId(dbVictim.Id, targetForm.Id);

            StatsProcedures.AddStat(dbVictim.MembershipId, StatsProcedures.Stat__TimesAnimateTFed, 1);
            StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__TimesAnimateTFing, 1);
        }
Ejemplo n.º 11
0
        private static decimal CalculateTFEBonusBuff(Player victim, Player attacker)
        {
            var attackerTFEnergyBonus   = ItemProcedures.GetPlayerBuffs(attacker).SpellExtraTFEnergyPercent();
            var victimTFEnergyReduction = ItemProcedures.GetPlayerBuffs(victim).SpellTFEnergyDamageResistance();
            // Collect the attacker ExtraTFEnergyPercent and modify it by the defenders TFEnergyDamageResistance
            var modifiedTFEnergyPercent = 1 + ((attackerTFEnergyBonus - victimTFEnergyReduction) / 100M);

            // Cap the damage modifier at 0.5 / 2.0
            if (modifiedTFEnergyPercent < 0.5M)
            {
                modifiedTFEnergyPercent = 0.5M;
            }
            if (modifiedTFEnergyPercent > 2.0M)
            {
                modifiedTFEnergyPercent = 2.0M;
            }

            return(modifiedTFEnergyPercent);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Spawns Narcissa into the world and sets her initial blank AI Directive
        /// </summary>
        public static void SpawnFaeBoss()
        {
            var faeboss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.FaebossBotId
            });

            if (faeboss == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = FirstName,
                    LastName     = LastName,
                    Location     = SpawnLocation,
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = FaeBossFormId,
                    Money        = 1000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 25,
                    BotId        = AIStatics.FaebossBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                AIDirectiveProcedures.GetAIDirective(id);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.NARCISSA_RUNE, PlayerId = faebossEF.Id
                    });
                }
            }
        }
Ejemplo n.º 13
0
        public virtual ActionResult MyInventory()
        {
            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            if (me.MembershipId == myMembershipId)
            {
                ViewBag.BelongsToPlayer = "block";
            }
            else
            {
                ViewBag.BelongsToPlayer = "none";
            }


            var output = new InventoryBonusesViewModel
            {
                Items = DomainRegistry.Repository.Find(new GetItemsOwnedByPlayer {
                    OwnerId = me.Id
                }).Where(i => i.EmbeddedOnItem == null),
                Bonuses           = ItemProcedures.GetPlayerBuffs(me),
                Health            = me.Health,
                MaxHealth         = me.MaxHealth,
                Mana              = me.Mana,
                MaxMana           = me.MaxMana,
                CurrentCarryCount = DomainRegistry.Repository.FindSingle(new GetCurrentCarryWeight {
                    PlayerId = me.Id
                }),
                MaxInventorySize = ItemProcedures.GetInventoryMaxSize(me)
            };

            ViewBag.ErrorMessage    = TempData["Error"];
            ViewBag.SubErrorMessage = TempData["SubError"];
            ViewBag.Result          = TempData["Result"];

            ViewBag.ShowDetailLinks   = true;
            ViewBag.ItemsUsedThisTurn = me.ItemsUsedThisTurn;


            return(View(MVC.PvP.Views.Inventory, output));
        }
Ejemplo n.º 14
0
        public virtual ActionResult UnembedRunes()
        {
            var me = PlayerProcedures.GetPlayerFromMembership(User.Identity.GetUserId());

            try
            {
                TempData["Result"] = DomainRegistry.Repository.Execute(new UnembedAllRunes {
                    PlayerId = me.Id
                });
                IPlayerRepository playerRepo = new EFPlayerRepository();
                var newMe = playerRepo.Players.FirstOrDefault(p => p.Id == me.Id);
                newMe.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newMe));
                playerRepo.SavePlayer(newMe);
            }
            catch (DomainException e)
            {
                TempData["Error"] = e.Message;
            }

            return(RedirectToAction(MVC.Item.MyInventory()));
        }
Ejemplo n.º 15
0
        public static void Spawn()
        {
            var boss = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId
            {
                BotId = AIStatics.MotorcycleGangLeaderBotId
            });

            if (boss == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = BossFirstName,
                    LastName     = BossLastName,
                    Location     = SpawnLocation,
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = BossFormId,
                    Money        = 2000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 20,
                    BotId        = AIStatics.MotorcycleGangLeaderBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.MOTORCYCLE_RUNE, PlayerId = bossEF.Id
                    });
                }
            }
        }
Ejemplo n.º 16
0
        public static void SpawnDonna()
        {
            var donna = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.DonnaBotId
            });

            if (donna == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = FirstName,
                    LastName     = LastName,
                    Location     = "ranch_bedroom",
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = DonnaFormSourceId,
                    Money        = 1000,
                    Level        = 20,
                    BotId        = AIStatics.DonnaBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.DONNA_RUNE, PlayerId = donnaEF.Id
                    });
                }
            }
        }
Ejemplo n.º 17
0
        public static Player ProcessQuestStatePreactions(Player player, QuestState questState)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var dbPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id);

            foreach (var p in questState.QuestStatePreactions.ToList())
            {
                // try to parse the value from string into number, if it fails, default to 0
                decimal valueAsNumber = 0;
                if (!Decimal.TryParse(p.ActionValue, out valueAsNumber))
                {
                    valueAsNumber = 0;
                }

                // change form
                if (p.ActionType == (int)QuestStatics.PreactionType.Form)
                {
                    DomainRegistry.Repository.Execute(new ChangeForm
                    {
                        PlayerId     = dbPlayer.Id,
                        FormSourceId = System.Convert.ToInt32(p.ActionValue)
                    });
                }

                // move player
                else if (p.ActionType == (int)QuestStatics.PreactionType.MoveToLocation)
                {
                    var loc = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == p.ActionValue);
                    if (loc != null)
                    {
                        dbPlayer.dbLocationName = p.ActionValue;
                    }
                }

                // change willpower
                else if (p.ActionType == (int)QuestStatics.PreactionType.Willpower)
                {
                    if (p.AddOrSet == (int)QuestStatics.AddOrSet.Set)
                    {
                        dbPlayer.Health = valueAsNumber;
                    }
                    else if (p.AddOrSet == (int)QuestStatics.AddOrSet.Add_Number)
                    {
                        dbPlayer.Health += valueAsNumber;
                    }
                }

                // change mana
                else if (p.ActionType == (int)QuestStatics.PreactionType.Mana)
                {
                    if (p.AddOrSet == (int)QuestStatics.AddOrSet.Set)
                    {
                        dbPlayer.Mana = valueAsNumber;
                    }
                    else if (p.AddOrSet == (int)QuestStatics.AddOrSet.Add_Number)
                    {
                        dbPlayer.Mana += valueAsNumber;
                    }
                }

                // update or set a variable
                else if (p.ActionType == (int)QuestStatics.PreactionType.Variable)
                {
                    if (p.AddOrSet == (int)QuestStatics.AddOrSet.Set)
                    {
                        QuestProcedures.SetQuestPlayerVariable(p.QuestId, dbPlayer.Id, p.VariableName, p.ActionValue);
                    }
                    else if (p.AddOrSet == (int)QuestStatics.AddOrSet.Add_Number)
                    {
                        QuestProcedures.EditQuestPlayerVariable(p.QuestId, dbPlayer.Id, p.VariableName, p.ActionValue);
                    }
                }
            }

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

            return(dbPlayer);
        }
Ejemplo n.º 18
0
        public static void SpawnAIPsychopaths(int count)
        {
            var rand = new Random();
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var turnNumber = PvPWorldStatProcedures.GetWorldTurnNumber();
            var botCount   = playerRepo.Players.Count(b => b.BotId == AIStatics.PsychopathBotId);

            for (var i = (0 + botCount); i < (count + botCount); i++)
            {
                var cmd = new CreatePlayer
                {
                    FirstName          = "Psychopath",
                    Location           = LocationsStatics.GetRandomLocationNotInDungeon(),
                    Health             = 100000,
                    MaxHealth          = 100000,
                    Mana               = 100000,
                    MaxMana            = 100000,
                    BotId              = AIStatics.PsychopathBotId,
                    UnusedLevelUpPerks = 0,
                    XP       = 0,
                    Money    = 100,
                    LastName = NameService.GetRandomLastName(),
                    Gender   = i % 2 == 1 ? PvPStatics.GenderMale : PvPStatics.GenderFemale,
                };


                var strength = GetPsychopathLevel(turnNumber);

                if (strength == 1)
                {
                    cmd.Level = 1;
                }
                else if (strength == 3)
                {
                    cmd.FirstName = "Fierce " + cmd.FirstName;
                    cmd.Level     = 3;
                }
                else if (strength == 5)
                {
                    cmd.FirstName = "Wrathful " + cmd.FirstName;
                    cmd.Level     = 5;
                }
                else if (strength == 7)
                {
                    cmd.FirstName = "Loathful " + cmd.FirstName;
                    cmd.Level     = 7;
                }
                else if (strength == 9)
                {
                    cmd.FirstName = "Soulless " + cmd.FirstName;
                    cmd.Level     = 9;
                }

                var idAndFormName = GetPsychoFormFromLevelAndSex(cmd.Level, cmd.Gender);
                cmd.FormSourceId = idAndFormName.Item1;

                // assert this name isn't already taken
                var ghost = playerRepo.Players.FirstOrDefault(p => p.FirstName == cmd.FirstName && p.LastName == cmd.LastName);
                if (ghost != null)
                {
                    continue;
                }

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

                // give this bot a random skill
                var eligibleSkills = SkillStatics.GetLearnablePsychopathSkills().ToList();

                double max       = eligibleSkills.Count;
                var    randIndex = Convert.ToInt32(Math.Floor(rand.NextDouble() * max));

                var skillToLearn = eligibleSkills.ElementAt(randIndex);
                SkillProcedures.GiveSkillToPlayer(id, skillToLearn.Id);

                // give this bot the Psychpathic perk
                if (strength == 1)
                {
                    EffectProcedures.GivePerkToPlayer(PsychopathicForLevelOneEffectSourceId, id);
                }
                else if (strength == 3)
                {
                    EffectProcedures.GivePerkToPlayer(PsychopathicForLevelThreeEffectSourceId, id);
                }
                else if (strength == 5)
                {
                    EffectProcedures.GivePerkToPlayer(PsychopathicForLevelFiveEffectSourceId, id);
                }
                else if (strength == 7)
                {
                    EffectProcedures.GivePerkToPlayer(PsychopathicForLevelSevenEffectSourceId, id);
                }
                else if (strength == 9)
                {
                    EffectProcedures.GivePerkToPlayer(PsychopathicForLevelNineEffectSourceId, id);
                }

                // give this psycho a new rune with some random chance it is a higher level than they are, to a max of level 13
                var random = new Random(Guid.NewGuid().GetHashCode());
                var roll   = random.NextDouble();

                if (roll < .1)
                {
                    strength += 4;
                }
                else if (roll < .3)
                {
                    strength += 2;
                }

                var quantity = Math.Floor(random.NextDouble() * 2) + 1; // 1 or 2

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

                var psychoEF = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                psychoEF.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(psychoEF));
                playerRepo.SavePlayer(psychoEF);
            }
        }
        public static void RunActions(int turnNumber)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var merchant = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.LindellaBotId && f.Mobility == PvPStatics.MobilityFull);

            if (merchant != null && merchant.Mobility == PvPStatics.MobilityFull)
            {
                var directive = AIDirectiveProcedures.GetAIDirective(merchant.Id);

                if (directive.TargetLocation.IsEmpty())
                {
                    AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "270_west_9th_ave");
                }

                if (directive.TargetLocation != merchant.dbLocationName)
                {
                    var newplace = AIProcedures.MoveTo(merchant, directive.TargetLocation, 6);
                    merchant.dbLocationName = newplace;
                }

                // if the merchant has arrived, set a new target for next time.
                // Does this count as turning Lindella into a snail?
                if (directive.TargetLocation == merchant.dbLocationName && turnNumber % 2 == 0)
                {
                    if (merchant.dbLocationName == "270_west_9th_ave")
                    {
                        AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "street_15th_south");
                    }
                    else if (merchant.dbLocationName == "street_15th_south")
                    {
                        AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "street_220_sunnyglade_drive");
                    }
                    else if (merchant.dbLocationName == "street_220_sunnyglade_drive")
                    {
                        AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "street_70e9th");
                    }
                    else if (merchant.dbLocationName == "street_70e9th")
                    {
                        AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "street_130_main");
                    }
                    else if (merchant.dbLocationName == "street_130_main")
                    {
                        AIDirectiveProcedures.SetAIDirective_MoveTo(merchant.Id, "270_west_9th_ave");
                    }
                }

                playerRepo.SavePlayer(merchant);
                var box = ItemProcedures.GetPlayerBuffs(merchant);

                if ((merchant.Health / merchant.MaxHealth) < .75M)
                {
                    if (merchant.Health < merchant.MaxHealth)
                    {
                        DomainRegistry.Repository.Execute(new Cleanse {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                        DomainRegistry.Repository.Execute(new Cleanse {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                    }
                }
                else
                {
                    if (merchant.Mana < merchant.MaxMana)
                    {
                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                        DomainRegistry.Repository.Execute(new Meditate {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                        DomainRegistry.Repository.Execute(new Cleanse {
                            PlayerId = merchant.Id, Buffs = box, NoValidate = true
                        });
                    }
                }

                if (turnNumber % 16 == 1)
                {
                    DomainRegistry.Repository.Execute(new RestockNPC {
                        BotId = AIStatics.LindellaBotId
                    });
                    DomainRegistry.Repository.Execute(new RestockNPC {
                        BotId = AIStatics.LoremasterBotId
                    });
                }
            }
        }
Ejemplo n.º 20
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..");
        }
Ejemplo n.º 21
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!");
        }
Ejemplo n.º 22
0
        public virtual ActionResult Choice(int Id)
        {
            IQuestRepository repo = new EFQuestRepository();

            var myMembershipId = User.Identity.GetUserId();
            var me             = PlayerProcedures.GetPlayerFromMembership(myMembershipId);

            // assert player is animate
            if (me.Mobility != PvPStatics.MobilityFull)
            {
                TempData["Error"] = "You are not animate.";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            // assert player has enough AP
            if (me.ActionPoints < QuestStatics.ActionAPCost)
            {
                TempData["Error"]    = "You don't have enough action points for this.";
                TempData["SubError"] = "Wait a while; you will get more action points soon.";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            var currentState      = QuestProcedures.GetQuestState(me.InQuestState);
            var desiredConnection = QuestProcedures.GetQuestConnection(Id);
            var nextState         = QuestProcedures.GetQuestState(desiredConnection.QuestStateToId);

            // assert desired state is in same quest
            if (nextState.QuestId != me.InQuest || desiredConnection.QuestId != me.InQuest)
            {
                TempData["Error"] = "Unavailable";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            // assert a connection does exist between current state and chosen one
            if (desiredConnection.QuestStateFromId != me.InQuestState)
            {
                TempData["Error"] = "Unavailable";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            var output = new QuestPlayPageViewModel();

            output.Player               = PlayerProcedures.GetPlayerFormViewModel(me.Id);
            output.QuestStart           = QuestProcedures.GetQuest(me.InQuest);
            output.QuestPlayerVariables = QuestProcedures.GetAllQuestPlayerVariablesFromQuest(output.QuestStart.Id, me.Id);
            var buffs = ItemProcedures.GetPlayerBuffs(me);

            // assert player has the right requirements for this
            if (!QuestProcedures.QuestConnectionIsAvailable(desiredConnection, me, buffs, output.QuestPlayerVariables))
            {
                TempData["Error"] = "You're not able to do that.";
                return(RedirectToAction(MVC.Quest.Quest()));
            }

            // make rolls for pass / fail
            if (desiredConnection.RequiresRolls())
            {
                var passes = QuestProcedures.RollForQuestConnection(desiredConnection, me, buffs, output.QuestPlayerVariables);

                // player fails; reroute to the failure quest state
                if (!passes)
                {
                    nextState = QuestProcedures.GetQuestState(desiredConnection.QuestStateFailToId);
                    TempData["RollResult"] = "fail";
                }
                else
                {
                    TempData["RollResult"] = "pass";
                }
            }
            else
            {
                TempData["RollResult"] = "none";
            }

            QuestProcedures.PlayerSetQuestState(me, nextState);
            QuestProcedures.ProcessQuestStatePreactions(me, nextState);

            var keepPlayerOnline = me.LastActionTimestamp > DateTime.UtcNow.AddMinutes(-TurnTimesStatics.GetOfflineAfterXMinutes());

            PlayerProcedures.ChangePlayerActionMana(-1, 0, 0, me.Id, keepPlayerOnline);

            TempData["ConnectionText"] = desiredConnection.Text;

            return(RedirectToAction(MVC.Quest.Quest()));
        }
        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);
            }
        }
Ejemplo n.º 24
0
        public static void UpdateWorld()
        {
            var worldStats = DomainRegistry.Repository.FindSingle(new GetWorld());

            var turnNo = worldStats.TurnNumber;

            PvPStatics.LastGameTurn = turnNo;

            if (turnNo < PvPStatics.RoundDuration)
            {
                PvPStatics.AnimateUpdateInProgress = true;

                IServerLogRepository serverLogRepo = new EFServerLogRepository();
                var log = new ServerLog
                {
                    TurnNumber      = turnNo,
                    StartTimestamp  = DateTime.UtcNow,
                    FinishTimestamp = DateTime.UtcNow,
                    Errors          = 0,
                    FullLog         = "",
                    Population      = PlayerProcedures.GetWorldPlayerStats().CurrentOnlinePlayers,
                };
                log.AddLog($"Started new log for turn {turnNo} at <b>{DateTime.UtcNow}</b>.");
                serverLogRepo.SaveServerLog(log);
                var updateTimer = new Stopwatch();
                updateTimer.Start();

                IPlayerRepository playerRepo = new EFPlayerRepository();

                Player lindella = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LindellaBotId);
                Player wuffie   = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.WuffieBotId);

                #region spawn NPCS
                // make sure the NPCs have been spawned early turn
                if (turnNo <= 3)
                {
                    if (lindella == null)
                    {
                        BossProcedures_Lindella.SpawnLindella();
                        lindella = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LindellaBotId);
                    }

                    if (wuffie == null)
                    {
                        BossProcedures_PetMerchant.SpawnPetMerchant();
                        wuffie = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.WuffieBotId);
                    }

                    var fae = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.JewdewfaeBotId);
                    if (fae == null)
                    {
                        BossProcedures_Jewdewfae.SpawnFae();
                    }

                    var bartender = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.BartenderBotId);
                    if (bartender == null)
                    {
                        BossProcedures_Bartender.SpawnBartender();
                    }

                    var lorekeeper = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.LoremasterBotId);
                    if (lorekeeper == null)
                    {
                        BossProcedures_Loremaster.SpawnLoremaster();
                    }

                    var soulbinder = playerRepo.Players.FirstOrDefault(p => p.BotId == AIStatics.SoulbinderBotId);
                    if (soulbinder == null)
                    {
                        var id = DomainRegistry.Repository.Execute(new CreatePlayer
                        {
                            FirstName               = "Karin",
                            LastName                = "Kezesul-Adriz the Soulbinder",
                            FormSourceId            = 1000,
                            Location                = "stripclub_office",
                            Level                   = 10,
                            Mobility                = PvPStatics.MobilityFull,
                            Money                   = 0,
                            Gender                  = PvPStatics.GenderFemale,
                            Health                  = 9999,
                            MaxHealth               = 9999,
                            Mana                    = 9999,
                            MaxMana                 = 9999,
                            OnlineActivityTimestamp = DateTime.UtcNow,
                            BotId                   = AIStatics.SoulbinderBotId
                        });

                        var newSoulbinder = playerRepo.Players.FirstOrDefault(p => p.Id == id);
                        newSoulbinder.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newSoulbinder));
                        playerRepo.SavePlayer(newSoulbinder);
                    }
                }
                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started loading animate players");

                IEffectRepository effectRepo = new EFEffectRepository();

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started loading effects");
                var temporaryEffects = effectRepo.Effects.Where(e => !e.IsPermanent).ToList();
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished loading effects");
                var effectsToDelete = new List <Effect>();

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating effects");
                var effectsExpiringThisTurn = temporaryEffects.Where(e => e.Duration == 1).ToList();
                var activeOrExpiringEffects = temporaryEffects.Where(e => e.Duration > 0).ToList();

                foreach (var e in temporaryEffects)
                {
                    e.Duration--;
                    e.Cooldown--;

                    if (e.Duration < 0)
                    {
                        e.Duration = 0;
                    }

                    if (e.Cooldown <= 0)
                    {
                        effectsToDelete.Add(e);
                    }
                    else
                    {
                        effectRepo.SaveEffect(e);
                    }
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating effects");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started running effect-expiry actions");
                try
                {
                    JokeShopProcedures.RunEffectExpiryActions(effectsExpiringThisTurn);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR running effect-expiry actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished running effect-expiry actions");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired effects");
                foreach (var e in effectsToDelete)
                {
                    effectRepo.DeleteEffect(e.Id);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired effects");
                serverLogRepo.SaveServerLog(log);

                #region playerExtra / protection cooldown loop
                IPlayerExtraRepository playerExtraRepo = new EFPlayerExtraRepository();
                var extrasToIncrement            = playerExtraRepo.PlayerExtras.ToList();
                var extrasToIncrement_SaveList   = new List <PlayerExtra>();
                var extrasToIncrement_DeleteList = new List <PlayerExtra>();
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating protection change cooldown (" + extrasToIncrement.Count + ")");

                foreach (var e in extrasToIncrement)
                {
                    var owner = PlayerProcedures.GetPlayer(e.PlayerId);
                    if (PlayerProcedures.PlayerIsOffline(owner))
                    {
                        extrasToIncrement_SaveList.Add(e);
                    }
                }

                foreach (var e in extrasToIncrement_SaveList)
                {
                    if (e.ProtectionToggleTurnsRemaining > 0)
                    {
                        e.ProtectionToggleTurnsRemaining--;
                        playerExtraRepo.SavePlayerExtra(e);
                    }
                    else if (e.ProtectionToggleTurnsRemaining <= 0)
                    {
                        extrasToIncrement_DeleteList.Add(e);
                    }
                }

                foreach (var e in extrasToIncrement_DeleteList)
                {
                    playerExtraRepo.DeletePlayerExtra(e.Id);
                }

                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating protection change cooldown.");


                #region main player loop

                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[Players] SET TimesAttackingThisUpdate = 0, CleansesMeditatesThisRound = 0, ShoutsRemaining = 1, ActionPoints = ActionPoints + 10, ItemsUsedThisTurn = 0 WHERE Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints_Refill = ActionPoints_Refill + (ActionPoints % {TurnTimesStatics.GetActionPointLimit()} / 2) WHERE ActionPoints >= {TurnTimesStatics.GetActionPointLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints = {TurnTimesStatics.GetActionPointLimit()} WHERE ActionPoints > {TurnTimesStatics.GetActionPointLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints_Refill = {TurnTimesStatics.GetActionPointReserveLimit()} WHERE ActionPoints_Refill > {TurnTimesStatics.GetActionPointReserveLimit()} AND Mobility='full'" +

                                                           $"UPDATE [dbo].[Players] SET ActionPoints = ActionPoints + 20, ActionPoints_Refill = ActionPoints_Refill - 20 WHERE ActionPoints <= {TurnTimesStatics.GetActionPointLimit()-20} AND ActionPoints_Refill >= 20 AND Mobility='full'");

                        if (PvPStatics.ChaosMode)
                        {
                            context.Database.ExecuteSqlCommand($"Update [dbo].[Players] SET ActionPoints = {TurnTimesStatics.GetActionPointLimit()}, ActionPoints_Refill = {TurnTimesStatics.GetActionPointReserveLimit()}, Mana = MaxMana");
                        }

                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  ANIMATE SQL UPDATE SUCCEEDED!");
                        serverLogRepo.SaveServerLog(log);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ANIMATE SQL UPDATE FAILED", e));
                        serverLogRepo.SaveServerLog(log);
                    }
                }

                var timeCutoff    = DateTime.UtcNow.AddHours(-8);
                var playersToSave = playerRepo.Players
                                    .Where(p => p.Mobility == PvPStatics.MobilityFull && p.LastActionTimestamp > timeCutoff).ToList();

                foreach (var player in playersToSave)
                {
                    //Skip regen stuff for those in quests.
                    if (player.InQuest > 0)
                    {
                        continue;
                    }

                    // extra AP condition checks
                    if (player.Covenant > 0)
                    {
                        var playerCov = CovenantDictionary.IdNameFlagLookup.FirstOrDefault(c => c.Key == player.Covenant).Value;

                        // give this player an extra AP refill if they are at their safeground, scaled up by level
                        if (playerCov != null && !playerCov.HomeLocation.IsNullOrEmpty() && player.dbLocationName == playerCov.HomeLocation)
                        {
                            player.ActionPoints_Refill += .25M * playerCov.CovLevel;
                        }

                        // give this player an extra AP refill if they are on a location that their covenane has enchanted
                        var currentLocation = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == player.dbLocationName);

                        if (currentLocation != null && currentLocation.CovenantController == player.Covenant)
                        {
                            if (currentLocation.TakeoverAmount < 25)
                            {
                                player.ActionPoints_Refill += .05M;
                            }
                            else if (currentLocation.TakeoverAmount <= 50)
                            {
                                player.ActionPoints_Refill += .10M;
                            }
                            else if (currentLocation.TakeoverAmount <= 75)
                            {
                                player.ActionPoints_Refill += .15M;
                            }
                            else if (currentLocation.TakeoverAmount < 100)
                            {
                                player.ActionPoints_Refill += .20M;
                            }
                            else if (currentLocation.TakeoverAmount >= 100)
                            {
                                player.ActionPoints_Refill += .25M;
                            }
                        }

                        // make sure AP reserve stays within maximum amount
                        if (player.ActionPoints_Refill > TurnTimesStatics.GetActionPointReserveLimit())
                        {
                            player.ActionPoints_Refill = TurnTimesStatics.GetActionPointReserveLimit();
                        }
                    }

                    var buffs = ItemProcedures.GetPlayerBuffs(player);
                    player.Health += buffs.HealthRecoveryPerUpdate();
                    player.Mana   += buffs.ManaRecoveryPerUpdate();

                    player.ReadjustMaxes(buffs);

                    playerRepo.SavePlayer(player);
                }

                log.AddLog($"{updateTimer.ElapsedMilliseconds}:  Finished updating animate players ({playersToSave.Count})");
                serverLogRepo.SaveServerLog(log);

                #endregion main player loop

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating inanimate/animal players");


                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[Players] SET TimesAttackingThisUpdate = 0, ItemsUsedThisTurn = 0 WHERE (Mobility = 'inanimate' OR Mobility = 'animal') AND BotId = 0");
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating inanimate/animal players");
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR UPDATING INANIMATE/ANIMAL PLAYERS", e));
                    }
                }

                serverLogRepo.SaveServerLog(log);

                #region decrement mind control timers
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started mind control cooldown.");

                using (var context = new StatsContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[MindControls] SET TurnsRemaining = TurnsRemaining - 1");
                        context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[MindControls] WHERE TurnsRemaining <= 0");
                        context.Database.ExecuteSqlCommand("UPDATE [dbo].[MindControls] SET TimesUsedThisTurn = 0");

                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished mind control cooldown.");
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "MIND CONTROL COOLDOWN UPDATE FAILED", e));
                    }
                }
                #endregion

                serverLogRepo.SaveServerLog(log);

                PvPStatics.AnimateUpdateInProgress = false;

                // bump down the timer on all items that are reuseable consumables
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started updating items on cooldown");
                IItemRepository itemsRepo     = new EFItemRepository();
                var             itemsToUpdate = itemsRepo.Items.Where(i => i.TurnsUntilUse > 0).ToList();

                foreach (var item in itemsToUpdate)
                {
                    item.TurnsUntilUse--;
                }

                foreach (var item in itemsToUpdate)
                {
                    itemsRepo.SaveItem(item);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished updating items on cooldown");
                serverLogRepo.SaveServerLog(log);

                // find the ids for the merchants Lindella and Skaldyr
                var skaldyr      = PlayerProcedures.GetPlayerFromBotId(AIStatics.LoremasterBotId);
                var soulbinderId = PlayerProcedures.GetPlayerFromBotId(AIStatics.SoulbinderBotId).Id;

                // have abandoned items go to Lindella
                if (turnNo % 11 == 3 && lindella.Mobility == PvPStatics.MobilityFull)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started collecting all abandoned items for Lindella");

                    using (var context = new StatsContext())
                    {
                        try
                        {
                            context.Database.ExecuteSqlCommand($"UPDATE [dbo].[Items] SET OwnerId = {lindella.Id}, dbLocationName = '', PvPEnabled = {(int)GameModeStatics.GameModes.Any}, TimeDropped = '{DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")}' " +
                                                               $"FROM DbStaticItems WHERE dbLocationName <> '' AND dbLocationName IS NOT NULL AND TimeDropped < DATEADD(hour, -8, GETUTCDATE()) AND OwnerId IS NULL AND DbStaticItems.Id = Items.ItemSourceId AND ItemType != '{PvPStatics.ItemType_Pet}' AND ItemSourceId != {ItemStatics.ItemType_DungeonArtifactItemSourceId};" +
                                                               $"UPDATE [dbo].[Players] SET dbLocationName = '' FROM Items WHERE Items.FormerPlayerId = Players.Id AND Items.OwnerId = {lindella.Id};");



                            log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished collecting all abandoned items for Lindella");
                        }
                        catch (Exception e)
                        {
                            log.Errors++;
                            log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR collecting all abandoned items for Lindella", e));
                        }
                    }
                }

                // delete all consumable type items that have been sitting around on the ground for too long
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired consumables");
                DomainRegistry.Repository.Execute(new DeleteExpiredConsumablesOnGround());
                DomainRegistry.Repository.Execute(new DeleteExpiredConsumablesOnMerchants {
                    LindellaId = lindella.Id, LorekeeperId = skaldyr.Id
                });

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired consumables");
                serverLogRepo.SaveServerLog(log);

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting expired runes");
                try
                {
                    DomainRegistry.Repository.Execute(new DeleteExpiredRunesOnMerchants());
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR deleting expired runes", e));
                    log.Errors++;
                }

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting expired runes");

                serverLogRepo.SaveServerLog(log);

                // allow all items that have been recently equipped to be taken back off
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started resetting items that have been recently equipped");
                var recentlyEquipped = itemsRepo.Items.Where(i => i.EquippedThisTurn).ToList();

                foreach (var item in recentlyEquipped)
                {
                    item.EquippedThisTurn = false;
                    itemsRepo.SaveItem(item);
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished resetting items that have been recently equipped");

                #region give covenants money based on territories
                if (turnNo % 6 == 0)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started giving covenants money from territories");
                    ICovenantRepository covRepo = new EFCovenantRepository();
                    var covs = covRepo.Covenants.Where(c => c.HomeLocation != null && c.HomeLocation != "").ToList();


                    foreach (var c in covs)
                    {
                        var locationControlledSum = CovenantProcedures.GetLocationControlCount(c);
                        var moneyGain             = (decimal)Math.Floor(Convert.ToDouble(locationControlledSum));
                        c.Money += moneyGain;

                        if (moneyGain > 0)
                        {
                            CovenantProcedures.WriteCovenantLog("Your covenant collected " + moneyGain + " Arpeyjis from the locations you have enchanted.", c.Id, false);
                        }
                        covRepo.SaveCovenant(c);
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished giving covenants money from territories");
                }
                #endregion

                serverLogRepo.SaveServerLog(log);

                #region drop dungeon artifacts and spawn demons if needed

                try
                {
                    if (turnNo % 7 == 2)
                    {
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  Starting dungeon item / demon spawning");
                        var dungeonArtifactCount = itemsRepo.Items.Count(i => i.ItemSourceId == ItemStatics.ItemType_DungeonArtifactItemSourceId);
                        for (var x = 0; x < PvPStatics.DungeonArtifact_SpawnLimit - dungeonArtifactCount; x++)
                        {
                            var randDungeon = LocationsStatics.GetRandomLocation_InDungeon();

                            var cmd = new CreateItem
                            {
                                dbLocationName   = randDungeon,
                                OwnerId          = null,
                                EquippedThisTurn = false,
                                IsPermanent      = true,
                                Level            = 0,
                                PvPEnabled       = 2,
                                IsEquipped       = false,
                                TurnsUntilUse    = 0,
                                ItemSourceId     = ItemStatics.ItemType_DungeonArtifactItemSourceId
                            };
                            DomainRegistry.Repository.Execute(cmd);
                        }


                        IEnumerable <Player> demons = playerRepo.Players.Where(i => i.FormSourceId == PvPStatics.DungeonDemonFormSourceId);
                        var dungeonDemonCount       = demons.Count();

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

                        var demonNames = XmlResourceLoader.Load <List <string> >("TT.Domain.XMLs.DungeonDemonNames.xml");

                        for (var x = 0; x < PvPStatics.DungeonDemon_Limit - dungeonDemonCount; x++)
                        {
                            var randDungeon = LocationsStatics.GetRandomLocation_InDungeon();

                            // pull a random last demon name
                            double maxDemonNameCount = demonNames.Count();
                            var    num           = randLevel.NextDouble();
                            var    demonIndex    = Convert.ToInt32(Math.Floor(num * maxDemonNameCount));
                            var    demonlastName = demonNames.ElementAt(demonIndex);

                            // if there's already a demon with this last name, reroll and try again
                            if (demons.FirstOrDefault(d => d.LastName == demonlastName) != null)
                            {
                                x--;
                                continue;
                            }


                            var levelRoll = randLevel.NextDouble();
                            var level     = (int)Math.Floor(levelRoll * 8 + 3);

                            var cmd = new CreatePlayer
                            {
                                BotId        = AIStatics.DemonBotId,
                                FirstName    = "Spirit of ",
                                LastName     = demonlastName,
                                Mobility     = PvPStatics.MobilityFull,
                                FormSourceId = AIStatics.DungeonDemonFormId,
                                Gender       = PvPStatics.GenderFemale,
                                GameMode     = 2,
                                Health       = 10000,
                                Mana         = 10000,
                                Covenant     = -1,
                                Location     = randDungeon,
                                Level        = level,
                                MaxHealth    = 10000,
                                MaxMana      = 10000,
                            };

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

                            var newDemon = playerRepo.Players.FirstOrDefault(p => p.Id == id);

                            if (cmd.Level <= 5)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookMediumItemSourceId);
                            }
                            else if (cmd.Level <= 7)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookLargeItemSourceId);
                            }

                            else if (cmd.Level > 7)
                            {
                                ItemProcedures.GiveNewItemToPlayer(newDemon, ItemStatics.SpellbookGiantItemSourceId);
                            }

                            newDemon.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(newDemon));
                            playerRepo.SavePlayer(newDemon);
                        }
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  FINISHED dungeon item / demon spawning");
                    }
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running dungeon actions", e));
                }


                #endregion

                serverLogRepo.SaveServerLog(log);

                #region forcibly terminate duels that have timed out
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started duel updates");
                try
                {
                    IDuelRepository duelRepo = new EFDuelRepository();
                    var             duels    = duelRepo.Duels.Where(d => d.Status == DuelProcedures.ACTIVE).ToList();

                    foreach (var d in duels)
                    {
                        // if the duel has timed out, end it forcibly
                        if ((turnNo - d.StartTurn) >= PvPStatics.MaximumDuelTurnLength)
                        {
                            DuelProcedures.EndDuel(d.Id, DuelProcedures.TIMEOUT);
                        }
                    }

                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Successfully completed duel updates");
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR completing duel updates", e));
                }
                #endregion duel updates

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Lindella actions");
                serverLogRepo.SaveServerLog(log);
                try
                {
                    BossProcedures_Lindella.RunActions(turnNo);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running Lindella action", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Lindella actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Wuffie actions");
                serverLogRepo.SaveServerLog(log);
                try
                {
                    BossProcedures_PetMerchant.RunPetMerchantActions(turnNo);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running Wuffie actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Wuffie actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started running effect-related actions");
                try
                {
                    JokeShopProcedures.RunEffectActions(activeOrExpiringEffects);
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, " ERROR running effect-related actions", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished running effect-related actions");
                serverLogRepo.SaveServerLog(log);

                #region furniture
                if (turnNo % 6 == 0)
                {
                    // move some furniture around on the market
                    try
                    {
                        FurnitureProcedures.MoveFurnitureOnMarket();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + "ERROR MOVING FURNITURE ON MARKET:  " + e);
                    }

                    // move Jewdewfae to a new location if she has been in one place for more than 48 turns, 8 hours
                    try
                    {
                        var fae   = PlayerProcedures.GetPlayerFromBotId(-6);
                        var faeAI = AIDirectiveProcedures.GetAIDirective(fae.Id);

                        // if the turn since her last move has been long enough, relocate her
                        if (turnNo - (int)faeAI.Var2 > 48)
                        {
                            log.AddLog(updateTimer.ElapsedMilliseconds + ":  FORCED JEWDEWFAE TO MOVE.");
                            BossProcedures_Jewdewfae.MoveToNewLocation();
                        }
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + "ERROR TRYING TO MOVE JEWDEWFAE:  " + e);
                    }
                }
                #endregion furniture

                #region bosses

                // DONNA
                if (worldStats.Boss_Donna == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Donna actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Donna.RunDonnaActions();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Donna actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Donna actions");
                }

                // VALENTINE
                if (worldStats.Boss_Valentine == AIStatics.ACTIVE || PlayerProcedures.GetAnimatePlayerFromBotId(AIStatics.ValentineBotId) != null)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Valentine actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Valentine.RunValentineActions();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Valentine actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Valentine actions");
                }

                // BIMBO
                if (worldStats.Boss_Bimbo == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Bimbo actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_BimboBoss.RunActions(turnNo);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Bimbo actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Bimbo actions");
                }

                // THIEVES
                if (worldStats.Boss_Thief == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Thieves actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Thieves.RunThievesAction(turnNo);
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Thieves actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Thieves actions");
                }

                // SISTERS
                if (worldStats.Boss_Sisters == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Sisters actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_Sisters.RunSistersAction();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Sisters actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Sisters actions");
                }

                // FAEBOSS
                if (worldStats.Boss_Faeboss == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started Narcissa actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_FaeBoss.RunTurnLogic();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running Narcissa actions", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished Narcissa actions");
                }

                // BIKER GANG BOSS
                if (worldStats.Boss_MotorcycleGang == AIStatics.ACTIVE)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started BikerBoss actions");
                    serverLogRepo.SaveServerLog(log);
                    try
                    {
                        BossProcedures_MotorcycleGang.RunTurnLogic();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(updateTimer.ElapsedMilliseconds + ":  BikerBoss ERROR:  " + e);
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished BikerBoss actions");
                }

                #endregion bosses

                // psychopaths
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started psychopath actions");
                serverLogRepo.SaveServerLog(log);

                var psychoExceptions = AIProcedures.RunPsychopathActions(worldStats);

                foreach (var e in psychoExceptions)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running pycho action", e));
                }

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished psychopath actions");

                // minibosses
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started miniboss actions");
                serverLogRepo.SaveServerLog(log);

                var minibossExceptions = BossProcedures_Minibosses.RunAll(worldStats.TurnNumber);

                foreach (var e in minibossExceptions)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Error running miniboss action", e));
                }

                serverLogRepo.SaveServerLog(log);
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished miniboss actions");

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Starting setting update status to done");
                try
                {
                    PvPWorldStatProcedures.UpdateWorldTurnCounter_UpdateDone();
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished setting update status to done");
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR setting update status to done: ", e));
                    log.Errors++;
                }

                serverLogRepo.SaveServerLog(log);

                try
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started stored procedure maintenance");
                    using (var context = new StatsContext())
                    {
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[LocationLogs] WHERE Timestamp < DATEADD(hour, -1, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[Messages] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE()) AND DoNotRecycleMe = 0");
                        context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[TFEnergies] WHERE Amount < .5");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[PlayerLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[ChatLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[AIDirectives] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE()) AND DoNotRecycleMe = 0");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[CovenantLogs] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[RPClassifiedAds] WHERE RefreshTimestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[TFEnergies] WHERE Timestamp < DATEADD(hour, -72, GETUTCDATE())");
                        context.Database.ExecuteSqlCommand(
                            "DELETE FROM [dbo].[SelfRestoreEnergies] WHERE Timestamp < DATEADD(hour, -4, GETUTCDATE())");

                        // move soulbound items on the ground to the soulbinding NPC.
                        context.Database.ExecuteSqlCommand(
                            $"UPDATE[dbo].[Items] SET OwnerId = {soulbinderId}, dbLocationName = '' WHERE dbLocationName <> '' AND SoulboundToPlayerId IS NOT NULL;");
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished stored procedure maintenance");
                }
                catch (Exception e)
                {
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR running stored procedure maintenance: ", e));
                    log.Errors++;
                }

                serverLogRepo.SaveServerLog(log);


                #region update joke shop
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating joke shop started.");
                try
                {
                    JokeShopProcedures.EjectOfflineCharacters();

                    if (new Random().Next(20) == 0)
                    {
                        LocationsStatics.MoveJokeShop();
                    }

                    ChallengeProcedures.CheckChallenges();
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Updating joke shop FAILED", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating joke shop completed.");
                serverLogRepo.SaveServerLog(log);
                #endregion update joke shop


                #region regenerate dungeon
                if (turnNo % 30 == 7)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Dungeon generation started.");
                    try
                    {
                        DungeonProcedures.GenerateDungeon();
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Dungeon generation FAILED", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Dungeon generation completed.");
                    serverLogRepo.SaveServerLog(log);
                }
                #endregion

                #region move tomb quest
                // Just to keep some things consistent, following the update pattern of the dungeon regen.
                if (turnNo > 6665 && turnNo % 30 == 7)
                {
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating tomb location started.");
                    try
                    {
                        // Get the quest stuff to start with.
                        int questId           = 39; //Nephthyma's Calling quest ID.
                        IQuestRepository repo = new EFQuestRepository();
                        var questStart        = repo.QuestStarts.FirstOrDefault(q => q.Id == questId);

                        if (questStart != null)
                        {
                            // Pick a random location.
                            string[] locationList   = { "mansion_mausoleum", "gym_laundry", "street_50e9th", "park_shrine" };
                            Random   locationRandom = new Random();
                            int      locationIndex  = locationRandom.Next(locationList.Length);
                            string   location       = locationList[locationIndex];

                            // Set it to the new location.

                            questStart.Location = location;
                            QuestWriterProcedures.SaveQuestStart(questStart);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Errors++;
                        log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "Updating tomb location FAILED", e));
                    }
                    log.AddLog(updateTimer.ElapsedMilliseconds + ":  Updating tomb location completed.");
                    serverLogRepo.SaveServerLog(log);
                }
                #endregion

                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Started deleting unwanted psycho items/pets on Lindella/Wuffie");
                try
                {
                    DomainRegistry.Repository.Execute(new DeleteUnpurchasedPsychoItems());
                }
                catch (Exception e)
                {
                    log.Errors++;
                    log.AddLog(FormatExceptionLog(updateTimer.ElapsedMilliseconds, "ERROR deleting unwanted psycho items", e));
                }
                log.AddLog(updateTimer.ElapsedMilliseconds + ":  Finished deleting unwanted psycho items/pets on Lindella/Wuffie");
                log.FinishTimestamp = DateTime.UtcNow;
                serverLogRepo.SaveServerLog(log);
            }
        }
Ejemplo n.º 25
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);
                }
            }
        }
        public static void RunPetMerchantActions(int turnNumber)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var petMerchant = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.WuffieBotId);


            if (petMerchant.Mobility == PvPStatics.MobilityFull)
            {
                if (petMerchant.Health < petMerchant.MaxHealth || petMerchant.Mana < petMerchant.MaxMana)
                {
                    var buffs = ItemProcedures.GetPlayerBuffs(petMerchant);
                    if (petMerchant.Health < petMerchant.MaxHealth)
                    {
                        petMerchant.Health += 200;
                        var logmessage = "<span class='playerCleansingNotification'>" + petMerchant.GetFullName() + " cleansed here.</span>";
                        LocationLogProcedures.AddLocationLog(petMerchant.dbLocationName, logmessage);
                    }
                    if (petMerchant.Mana < petMerchant.MaxMana)
                    {
                        petMerchant.Mana += 200;
                        var logmessage = "<span class='playerMediatingNotification'>" + petMerchant.GetFullName() + " meditated here.</span>";
                        LocationLogProcedures.AddLocationLog(petMerchant.dbLocationName, logmessage);
                    }

                    petMerchant.NormalizeHealthMana();
                }

                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();

                var turnMod     = turnNumber % (24 * 4);
                var regionIndex = turnMod / 24;

                var newLocation = "";
                switch (regionIndex)
                {
                case 0:
                    newLocation = LocationsStatics.GetRandomLocation_InRegion("ranch_outside");
                    break;

                case 1:
                    newLocation = LocationsStatics.GetRandomLocation_InRegion("forest");
                    break;

                case 2:
                    newLocation = LocationsStatics.GetRandomLocation_InRegion("campground");
                    break;

                default:
                    newLocation = LocationsStatics.GetRandomLocation_InRegion("park");
                    break;
                }

                var actualNewLocation = AIProcedures.MoveTo(petMerchant, newLocation, 6);
                petMerchant.dbLocationName = actualNewLocation;
                playerRepo.SavePlayer(petMerchant);

                if (turnNumber % 11 == 5)
                {
                    DomainRegistry.Repository.Execute(new MoveAbandonedPetsToWuffie {
                        WuffieId = petMerchant.Id
                    });
                }
            }
        }
Ejemplo n.º 27
0
        public static (bool, string) Attack(Player attackingPlayer, Player attackedPlayer, SkillViewModel skillBeingUsed, bool timestamp = true)
        {
            var result = "";

            var attacker = PlayerProcedures.GetPlayer(attackingPlayer.Id);
            var victim   = PlayerProcedures.GetPlayer(attackedPlayer.Id);

            if (victim.Mobility != PvPStatics.MobilityFull ||
                attacker.Mobility != PvPStatics.MobilityFull ||
                victim.GameMode == (int)GameModeStatics.GameModes.Invisible ||
                attacker.GameMode == (int)GameModeStatics.GameModes.Invisible)
            {
                return(false, "");
            }

            var complete = false;
            var logs     = new LogBox();

            // all of our checks seem to be okay.  So let's lower the player's mana and action points
            PlayerProcedures.ChangePlayerActionMana(-PvPStatics.AttackCost, 0, -PvPStatics.AttackManaCost, attacker.Id, timestamp);

            PlayerProcedures.LogCombatTimestampsAndAddAttackCount(victim, attacker);

            var attackerFullName = attacker.GetFullName();
            var victimFullName   = victim.GetFullName();

            // if the spell is a curse, give the effect and that's all
            if (skillBeingUsed.StaticSkill.GivesEffectSourceId != null)
            {
                var effectBeingGiven = EffectStatics.GetDbStaticEffect(skillBeingUsed.StaticSkill.GivesEffectSourceId.Value);

                EffectProcedures.GivePerkToPlayer(skillBeingUsed.StaticSkill.GivesEffectSourceId.Value, victim);

                if (attacker.Gender == PvPStatics.GenderMale && !effectBeingGiven.AttackerWhenHit_M.IsNullOrEmpty())
                {
                    logs.AttackerLog += effectBeingGiven.AttackerWhenHit_M;
                }
                else if (attacker.Gender == PvPStatics.GenderFemale && !effectBeingGiven.AttackerWhenHit_F.IsNullOrEmpty())
                {
                    logs.AttackerLog += effectBeingGiven.AttackerWhenHit_F;
                }
                else
                {
                    logs.AttackerLog += effectBeingGiven.AttackerWhenHit;
                }

                if (!String.IsNullOrEmpty(logs.AttackerLog))
                {
                    logs.AttackerLog += "<br><br>";
                }

                logs.LocationLog  = "<span class='playerAttackNotification'>" + attackerFullName + " cursed " + victimFullName + " with " + skillBeingUsed.StaticSkill.FriendlyName + ".</span>";
                logs.AttackerLog += "You cursed " + victimFullName + " with " + skillBeingUsed.StaticSkill.FriendlyName + ".";
                logs.AttackerLog += "  (+1 XP)  ";
                logs.AttackerLog += PlayerProcedures.GiveXP(attacker, 1);
                logs.VictimLog    = effectBeingGiven.MessageWhenHit;
                logs.VictimLog   += "  <span class='playerAttackNotification'>" + attackerFullName + " cursed you with <b>" + skillBeingUsed.StaticSkill.FriendlyName + "</b>.</b></span>  ";
                result            = logs.AttackerLog;
            }

            // the spell is a regular attack
            else
            {
                logs.LocationLog = "<span class='playerAttackNotification'>" + attackerFullName + " cast " + skillBeingUsed.StaticSkill.FriendlyName + " against " + victimFullName + ".</span>";
                logs.AttackerLog = "You cast " + skillBeingUsed.StaticSkill.FriendlyName + " against " + victimFullName + ".  ";
                logs.VictimLog   = "<span class='playerAttackNotification'>" + attackerFullName + " cast " + skillBeingUsed.StaticSkill.FriendlyName + " against you.</span>  ";

                var meBuffs       = ItemProcedures.GetPlayerBuffs(attacker);
                var targetedBuffs = ItemProcedures.GetPlayerBuffs(victim);

                var rand          = new Random(Guid.NewGuid().GetHashCode());
                var basehitChance = rand.NextDouble() * 100;

                var meDmgExtra = meBuffs.SpellExtraHealthDamagePercent();

                var criticalMissPercentChance = PvPStatics.CriticalMissPercentChance - meBuffs.SpellMisfireChanceReduction();

                var criticalPercentChance = meBuffs.ExtraSkillCriticalPercent() + PvPStatics.CriticalHitPercentChance;
                var evasionPercentChance  = targetedBuffs.EvasionPercent() - meBuffs.EvasionNegationPercent();
                var evasionUpgrade        = false;
                var failedAttack          = false;

                // clamp modifiedEvasion at 50% max
                if (evasionPercentChance > 50)
                {
                    evasionPercentChance = 50;
                }

                // critical miss!  damage caster instead
                if (basehitChance < (double)criticalMissPercentChance)
                {
                    // check if there is a health damage aspect to this spell
                    if (skillBeingUsed.StaticSkill.HealthDamageAmount > 0)
                    {
                        var amountToDamage = skillBeingUsed.StaticSkill.HealthDamageAmount *
                                             (1 + meDmgExtra / 100);
                        PlayerProcedures.DamagePlayerHealth(attacker.Id, amountToDamage);
                        logs.AttackerLog += $"Misfire!  Your spell accidentally lowered your own willpower by {amountToDamage:N2}.  ";
                        logs.VictimLog   += $"Misfire!  {GetPronoun_HisHer(attacker.Gender)} spell accidentally lowered {GetPronoun_hisher(attacker.Gender)} own willpower by {amountToDamage:N2}.";
                        result           += logs.AttackerLog;
                    }
                    failedAttack = true;
                }
                // spell is evaded
                else if (basehitChance < (double)criticalMissPercentChance + (double)evasionPercentChance)
                {
                    // Check for a crit to upgrade the miss to a hit
                    var criticalHitChance = rand.NextDouble() * 100;
                    if (criticalHitChance < (double)criticalPercentChance)
                    {
                        evasionUpgrade = true;
                    }
                    else
                    {
                        logs.AttackerLog += victimFullName + " managed to leap out of the way of your spell.";
                        logs.VictimLog   += "You managed to leap out of the way " + attackerFullName + "'s spell.";
                        result            = logs.AttackerLog;
                        failedAttack      = true;
                    }
                }

                // not a  miss, so let's deal some damage, possibly
                if (!failedAttack)
                {
                    decimal criticalModifier = 1;

                    if (evasionUpgrade)
                    {
                        logs.AttackerLog += "<b>Piercing hit!</b>  ";
                        logs.VictimLog   += "<b>Piercing hit!</b>  ";
                    }
                    else if (rand.NextDouble() * 100 < (double)criticalPercentChance)
                    {
                        criticalModifier  = 2;
                        logs.AttackerLog += "<b>Critical hit!</b>  ";
                        logs.VictimLog   += "<b>Critical hit!</b>  ";
                    }

                    var initialVictimHealth = victim.Health;

                    // check if there is a health damage aspect to this spell
                    if (skillBeingUsed.StaticSkill.HealthDamageAmount > 0)
                    {
                        var targetProt = targetedBuffs.SpellHealthDamageResistance();

                        // calculator the modifier as extra attack - defense.      15 - 20 = -5 modifier
                        var willpowerDamageModifierFromBonuses = 1 + ((meDmgExtra - targetProt) / 100.0M);

                        // cap the modifier at at 50 % IF the target is a human
                        if (willpowerDamageModifierFromBonuses < .5M)
                        {
                            willpowerDamageModifierFromBonuses = .5M;
                        }

                        // cap the modifier at 200 % IF the target is a human
                        if (willpowerDamageModifierFromBonuses > 2 && victim.BotId == AIStatics.ActivePlayerBotId)
                        {
                            willpowerDamageModifierFromBonuses = 2;
                        }

                        var totalHealthDamage = skillBeingUsed.StaticSkill.HealthDamageAmount * willpowerDamageModifierFromBonuses * criticalModifier;

                        // make sure damage is never in the negatives (which would heal instead)
                        if (totalHealthDamage < 0)
                        {
                            totalHealthDamage = 0;
                        }

                        PlayerProcedures.DamagePlayerHealth(victim.Id, totalHealthDamage);

                        // even though it's been done in the db, change the player health here as well
                        victim.Health -= totalHealthDamage;


                        logs.AttackerLog += $"Your spell lowered {GetPronoun_hisher(victim.Gender)} willpower by {Math.Round(totalHealthDamage, 2)}.  ";
                        logs.VictimLog   += $"{GetPronoun_HisHer(attacker.Gender)} spell lowered your willpower by {Math.Round(totalHealthDamage, 2)}.  ";
                        result           += logs.AttackerLog;
                    }

                    // if this skill has any TF power, add energy and check for form change
                    if (skillBeingUsed.StaticSkill.TFPointsAmount > 0)
                    {
                        var TFEnergyDmg   = meBuffs.SpellExtraTFEnergyPercent();
                        var TFEnergyArmor = targetedBuffs.SpellTFEnergyDamageResistance();

                        // calculator the modifier as extra attack - defense.
                        var tfEnergyDamageModifierFromBonuses = 1 + ((TFEnergyDmg - TFEnergyArmor) / 100.0M);

                        // cap the modifier at at 50 % IF the target is a human
                        if (tfEnergyDamageModifierFromBonuses < .5M)
                        {
                            tfEnergyDamageModifierFromBonuses = .5M;
                        }

                        // cap the modifier at at 200 % IF the target is a human
                        if (tfEnergyDamageModifierFromBonuses > 2 && victim.BotId == AIStatics.ActivePlayerBotId)
                        {
                            tfEnergyDamageModifierFromBonuses = 2;
                        }

                        var totalTFEnergyModifier = criticalModifier * tfEnergyDamageModifierFromBonuses;

                        LogBox tfEnergyResult;
                        (complete, tfEnergyResult) = TFEnergyProcedures.AddTFEnergyToPlayer(victim, attacker, skillBeingUsed, totalTFEnergyModifier, initialVictimHealth);
                        logs.Add(tfEnergyResult);

                        result = logs.AttackerLog;
                    }
                }
            }

            LocationLogProcedures.AddLocationLog(attacker.dbLocationName, logs.LocationLog);
            PlayerLogProcedures.AddPlayerLog(attacker.Id, logs.AttackerLog, false);
            PlayerLogProcedures.AddPlayerLog(victim.Id, logs.VictimLog, true);

            DomainRegistry.AttackNotificationBroker.Notify(victim.Id, logs.VictimLog);

            // if this is a psycho-on-psycho battle, have a chance for the victim bot to switch targets to the attacker bot
            if (attacker.BotId == AIStatics.PsychopathBotId && victim.BotId == AIStatics.PsychopathBotId)
            {
                var rand         = new Random(Guid.NewGuid().GetHashCode());
                var botAggroRoll = rand.NextDouble();
                if (botAggroRoll < .08)
                {
                    AIDirectiveProcedures.SetAIDirective_Attack(victim.Id, attacker.Id);
                }
            }

            return(complete, result);
        }
Ejemplo n.º 28
0
        public static List <Exception> RunPsychopathActions(WorldDetail worldDetail)
        {
            var rand = new Random(DateTime.Now.Millisecond);

            var errors = new List <Exception>();

            IPlayerRepository playerRepo = new EFPlayerRepository();


            //spawn in more bots if there are less than the default
            var botCount = playerRepo.Players.Count(b => b.BotId == AIStatics.PsychopathBotId && b.Mobility == PvPStatics.MobilityFull);

            if (botCount < PvPStatics.PsychopathDefaultAmount)
            {
                SpawnAIPsychopaths(PvPStatics.PsychopathDefaultAmount - botCount);
            }

            var bots = playerRepo.Players.Where(p => p.BotId == AIStatics.PsychopathBotId && p.Mobility == PvPStatics.MobilityFull).ToList();

            foreach (var bot in bots)
            {
                try
                {
                    // if bot is no longer fully animate or is null, skip them
                    if (bot == null || bot.Mobility != PvPStatics.MobilityFull)
                    {
                        continue;
                    }

                    bot.LastActionTimestamp = DateTime.UtcNow;

                    if (!EffectProcedures.PlayerHasActiveEffect(bot.Id, JokeShopProcedures.PSYCHOTIC_EFFECT))
                    {
                        #region drop excess items

                        var botItems = DomainRegistry.Repository.Find(new GetItemsOwnedByPsychopath {
                            OwnerId = bot.Id
                        }).ToList();

                        string[] itemTypes =
                        {
                            PvPStatics.ItemType_Hat,        PvPStatics.ItemType_Accessory, PvPStatics.ItemType_Pants,
                            PvPStatics.ItemType_Pet,        PvPStatics.ItemType_Shirt,     PvPStatics.ItemType_Shoes,
                            PvPStatics.ItemType_Underpants, PvPStatics.ItemType_Undershirt
                        };

                        foreach (var typeToDrop in itemTypes)
                        {
                            if (botItems.Count(i => i.ItemSource.ItemType == typeToDrop) > 1)
                            {
                                var dropList = botItems.Where(i => i.ItemSource.ItemType == typeToDrop).Skip(1);

                                foreach (var i in dropList)
                                {
                                    ItemProcedures.DropItem(i.Id);

                                    var name = "a";

                                    if (i.FormerPlayer != null)
                                    {
                                        name = "<b>" + i.FormerPlayer.FullName + "</b> the";
                                    }

                                    if (i.ItemSource.ItemType == PvPStatics.ItemType_Pet)
                                    {
                                        LocationLogProcedures.AddLocationLog(bot.dbLocationName,
                                                                             "<b>" + bot.GetFullName() + "</b> released " + name + " pet <b>" + i.ItemSource.FriendlyName + "</b> here.");
                                    }
                                    else
                                    {
                                        LocationLogProcedures.AddLocationLog(bot.dbLocationName,
                                                                             "<b>" + bot.GetFullName() + "</b> dropped " + name + " <b>" + i.ItemSource.FriendlyName + "</b> here.");
                                    }
                                }
                            }
                        }

                        #endregion
                    }

                    var botbuffs = ItemProcedures.GetPlayerBuffs(bot);

                    var meditates = 0;

                    // meditate if needed
                    if (bot.Mana < bot.MaxMana * .5M)
                    {
                        var manaroll = (int)Math.Floor(rand.NextDouble() * 4.0D);
                        for (var i = 0; i < manaroll; i++)
                        {
                            DomainRegistry.Repository.Execute(new Meditate
                            {
                                PlayerId   = bot.Id,
                                Buffs      = botbuffs,
                                NoValidate = true
                            });
                            meditates++;
                        }
                    }

                    // cleanse if needed, less if psycho has cleansed lately
                    if (bot.Health < bot.MaxHealth * .5M)
                    {
                        var healthroll = (int)Math.Floor(rand.NextDouble() * 4.0D);
                        for (var i = meditates; i < healthroll; i++)
                        {
                            DomainRegistry.Repository.Execute(new Cleanse
                            {
                                PlayerId   = bot.Id,
                                Buffs      = botbuffs,
                                NoValidate = true
                            });
                        }
                    }


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

                    // the bot has an attack target, so go chase it
                    if (directive.State == "attack")
                    {
                        var myTarget = PlayerProcedures.GetPlayer(directive.TargetPlayerId);
                        var(mySkills, weakenSkill, inanimateSkill) = GetPsychopathSkills(bot);

                        // if the target is offline, no longer animate, in the dungeon, or in the same form as the spells' target, go into idle mode
                        if (PlayerProcedures.PlayerIsOffline(myTarget) ||
                            myTarget.Mobility != PvPStatics.MobilityFull ||
                            mySkills.IsEmpty() || inanimateSkill == null ||
                            myTarget.FormSourceId == inanimateSkill.StaticSkill.FormSourceId ||
                            myTarget.IsInDungeon() ||
                            myTarget.InDuel > 0 ||
                            myTarget.InQuest > 0)
                        {
                            AIDirectiveProcedures.SetAIDirective_Idle(bot.Id);
                        }

                        // the target is okay for attacking
                        else
                        {
                            // the bot must move to its target location.
                            if (myTarget.dbLocationName != bot.dbLocationName)
                            {
                                if (botbuffs.MoveActionPointDiscount() > -100 && CanMove(worldDetail, myTarget))
                                {
                                    var maxSpaces = NumPsychopathMoveSpaces(bot);
                                    var newplace  = MoveTo(bot, myTarget.dbLocationName, maxSpaces);
                                    bot.dbLocationName = newplace;
                                }
                            }

                            // if the bot is now in the same place as the target, attack away, so long as the target is online and animate
                            if (bot.dbLocationName == myTarget.dbLocationName &&
                                !PlayerProcedures.PlayerIsOffline(myTarget) &&
                                myTarget.Mobility == PvPStatics.MobilityFull &&
                                CanAttack(worldDetail, bot, myTarget)
                                )
                            {
                                playerRepo.SavePlayer(bot);

                                var numAttacks = Math.Min(3, (int)(bot.Mana / PvPStatics.AttackManaCost));
                                var complete   = false;
                                for (var attackIndex = 0; attackIndex < numAttacks && !complete; ++attackIndex)
                                {
                                    var skill = SelectPsychopathSkill(myTarget, mySkills, weakenSkill, rand);
                                    (complete, _) = AttackProcedures.Attack(bot, myTarget, skill);
                                }

                                if (complete)
                                {
                                    EquipDefeatedPlayer(bot, myTarget);
                                }
                            }
                        }
                    }

                    // the bot has no target, so wander and try to find new targets and attack them.
                    else
                    {
                        if (botbuffs.MoveActionPointDiscount() > -100)
                        {
                            var newplace = MoveTo(bot, LocationsStatics.GetRandomLocationNotInDungeon(), 5);
                            bot.dbLocationName = newplace;
                        }


                        // attack stage
                        var playersHere = playerRepo.Players.Where
                                              (p => p.dbLocationName == bot.dbLocationName && p.Mobility == PvPStatics.MobilityFull &&
                                              p.Id != bot.Id && p.BotId == AIStatics.PsychopathBotId && p.Level >= bot.Level).ToList();

                        // filter out offline players and Lindella
                        var onlinePlayersHere = playersHere.Where(p => !PlayerProcedures.PlayerIsOffline(p)).ToList();

                        if (onlinePlayersHere.Count > 0)
                        {
                            var roll   = Math.Floor(rand.NextDouble() * onlinePlayersHere.Count);
                            var victim = onlinePlayersHere.ElementAt((int)roll);
                            AIDirectiveProcedures.SetAIDirective_Attack(bot.Id, victim.Id);
                            playerRepo.SavePlayer(bot);

                            var(mySkills, weakenSkill, inanimateSkill) = GetPsychopathSkills(bot);
                            if (!mySkills.IsEmpty())
                            {
                                var numAttacks = Math.Min(3, (int)(bot.Mana / PvPStatics.AttackManaCost));
                                var complete   = false;
                                for (var attackIndex = 0; attackIndex < numAttacks && !complete; ++attackIndex)
                                {
                                    var skill = SelectPsychopathSkill(victim, mySkills, weakenSkill, rand);
                                    (complete, _) = AttackProcedures.Attack(bot, victim, skill);
                                }

                                if (complete)
                                {
                                    EquipDefeatedPlayer(bot, victim);
                                }
                            }
                        }
                    }

                    playerRepo.SavePlayer(bot);
                }
                catch (Exception e)
                {
                    errors.Add(e);
                }
            }

            return(errors);
        }
Ejemplo n.º 29
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 void SpawnValentine()
        {
            var valentine = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.ValentineBotId
            });

            if (valentine == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = ValentineFirstName,
                    LastName     = ValentineLastName,
                    Location     = GetStanceLocation(),
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = ValentineFormSourceId,
                    Money        = 1000,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 30,
                    BotId        = AIStatics.ValentineBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                // give Valentine his reward item drop
                var createItemCmd = new CreateItem
                {
                    dbLocationName   = "",
                    EquippedThisTurn = false,
                    IsEquipped       = false,
                    IsPermanent      = false,
                    Level            = 6,
                    OwnerId          = id,
                    PvPEnabled       = -1,
                    ItemSourceId     = ItemStatics.GetStaticItem(QueensPantiesItemSourceId).Id
                };

                DomainRegistry.Repository.Execute(createItemCmd);

                // save his aiDirective, just for the sake of knowing his spawn turn
                IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
                var directive = new AIDirective
                {
                    OwnerId        = id,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    DoNotRecycleMe = true,
                };

                aiRepo.SaveAIDirective(directive);

                for (var i = 0; i < 2; i++)
                {
                    DomainRegistry.Repository.Execute(new GiveRune {
                        ItemSourceId = RuneStatics.VAMPIRE_RUNE, PlayerId = valentineEF.Id
                    });
                }
            }
        }