/// <summary>
        /// Retrieves the AI directive.  If no directive is found, a new one is automatically created with default settings
        /// </summary>
        /// <param name="botId">Id of the Player with this AI directive</param>
        /// <returns>the AI directive belonging to the passed in player ID</returns>
        public static AIDirective GetAIDirective(int botId)
        {
            IAIDirectiveRepository directiveRepo = new EFAIDirectiveRepository();

            var directive = directiveRepo.AIDirectives.FirstOrDefault(ad => ad.OwnerId == botId);

            if (directive == null)
            {
                directive = new AIDirective
                {
                    OwnerId        = botId,
                    State          = "idle", // attack, move, flee
                    TargetLocation = "",
                    TargetPlayerId = -1,
                    Timestamp      = DateTime.UtcNow,
                    Var1           = -1,
                    Var2           = -1,
                    Var3           = -1,
                    Var4           = -1,
                    Var5           = -1
                };
                directiveRepo.SaveAIDirective(directive);
            }

            return(directive);
        }
Example #2
0
        /// <summary>
        /// Clears Narcissa's target
        /// </summary>
        /// <param name="directive"></param>
        private static void ResetTarget(AIDirective directive)
        {
            IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
            var ai = aiRepo.AIDirectives.FirstOrDefault(a => a.Id == directive.Id);

            ai.Var1 = 0;
            aiRepo.SaveAIDirective(ai);
        }
Example #3
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
                    });
                }
            }
        }
        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);
            }
        }
 public void SaveAIDirective(AIDirective AIDirective)
 {
     if (AIDirective.Id == 0)
     {
         context.AIDirectives.Add(AIDirective);
     }
     else
     {
         var editMe = context.AIDirectives.Find(AIDirective.Id);
         if (editMe != null)
         {
             // dbEntry.Name = AIDirective.Name;
             // dbEntry.Message = AIDirective.Message;
             // dbEntry.TimeStamp = AIDirective.TimeStamp;
         }
     }
     context.SaveChanges();
 }
        public static decimal AddInteraction(Player player)
        {
            IPlayerRepository playerRepo = new EFPlayerRepository();
            var fae = playerRepo.Players.FirstOrDefault(f => f.BotId == AIStatics.JewdewfaeBotId);

            IAIDirectiveRepository aiRepo = new EFAIDirectiveRepository();
            var directive = aiRepo.AIDirectives.FirstOrDefault(i => i.OwnerId == fae.Id);


            if (directive == null)
            {
                directive = new AIDirective
                {
                    OwnerId   = fae.Id,
                    Timestamp = DateTime.UtcNow,
                    sVar1     = ";",
                };
            }

            // Var1 will keep track how how many interactions Jewdewfae has had.  Award a bit less XP based on how many people she has played with down to 15 at lowest
            var xpGain = 75 - directive.Var1 * 3;

            if (xpGain < 15)
            {
                xpGain = 15;
            }

            directive.Var1 += 1;

            // add this player's ID to the list of people interacted with; one playtime per location!
            directive.sVar1 += player.Id.ToString() + ";";

            aiRepo.SaveAIDirective(directive);

            if (directive.Var1 >= 18)
            {
                MoveToNewLocation();
            }

            LocationLogProcedures.AddLocationLog(fae.dbLocationName, "<b>Jewdewfae played with " + player.FirstName + " " + player.LastName + " here.</b>");

            return(xpGain);
        }
Example #7
0
        /// <summary>
        /// Determines whether Narcissa is currently chasing someone who is valid to be transformed still
        /// </summary>
        /// <param name="directive">AI Directive containing target Id</param>
        /// <returns>True if target is valid, false if not</returns>
        private static bool HasValidTarget(AIDirective directive)
        {
            if (directive == null || directive.Var1 == 0)
            {
                return(false);
            }

            var target = PlayerProcedures.GetPlayer((int)directive.Var1);

            // TODO:  This can probably be swapped out with Arrhae's "CanBeAttacked" method in the future.  But for now...
            if (target == null ||
                target.Mobility != PvPStatics.MobilityFull ||
                PlayerProcedures.PlayerIsOffline(target) ||
                target.IsInDungeon() ||
                target.InDuel > 0 ||
                target.InQuest > 0)
            {
                return(false);
            }

            return(true);
        }
        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
                    });
                }
            }
        }
Example #9
0
        public static void SpawnThieves()
        {
            var malethief = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.MaleRatBotId
            });

            if (malethief == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = MaleBossFirstName,
                    LastName     = MaleBossLastName,
                    Location     = "tavern_pool",
                    Gender       = PvPStatics.GenderMale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = MaleBossFormSourceId,
                    Money        = 0,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 5,
                    BotId        = AIStatics.MaleRatBotId
                };

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

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


                var aiRepo        = new EFAIDirectiveRepository();
                var maleDirective = new AIDirective
                {
                    OwnerId        = id,
                    DoNotRecycleMe = true,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    sVar1          = GetRichestPlayerIds(),
                    Var1           = 0,
                };
                aiRepo.SaveAIDirective(maleDirective);

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


            var femalethief = DomainRegistry.Repository.FindSingle(new GetPlayerByBotId {
                BotId = AIStatics.FemaleRatBotId
            });

            if (femalethief == null)
            {
                var cmd = new CreatePlayer
                {
                    FirstName    = FemaleBossFirstName,
                    LastName     = FemaleBossLastName,
                    Location     = "tavern_pool",
                    Gender       = PvPStatics.GenderFemale,
                    Health       = 100000,
                    Mana         = 100000,
                    MaxHealth    = 100000,
                    MaxMana      = 100000,
                    FormSourceId = FemaleBossFormSourceId,
                    Money        = 0,
                    Mobility     = PvPStatics.MobilityFull,
                    Level        = 7,
                    BotId        = AIStatics.FemaleRatBotId,
                };
                var id = DomainRegistry.Repository.Execute(cmd);

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

                var aiRepo          = new EFAIDirectiveRepository();
                var femaleDirective = new AIDirective
                {
                    OwnerId        = id,
                    DoNotRecycleMe = true,
                    Timestamp      = DateTime.UtcNow,
                    SpawnTurn      = PvPWorldStatProcedures.GetWorldTurnNumber(),
                    sVar1          = GetRichestPlayerIds(),
                    Var1           = 0,
                };
                aiRepo.SaveAIDirective(femaleDirective);

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