public string Process(INonPlayerCharacter npc, string command) { if (command == null) { //check if it is night if (GlobalReference.GlobalValues.GameDateTime.GameDateTime.Hour >= 12) { //check to see if they are not in the house if (npc.Room.Id != 26) { if (npc.Room.South != null) { npc.EnqueueCommand("South"); } else if (npc.Room.East != null) { npc.EnqueueCommand("East"); } } } else { foreach (IItem item in npc.Room.Items) { if (item is ICorpse) { step++; if (stateMachine == State.LookForCorpse) { stateMachine = State.BuryingCorpse; return($"Get {item.KeyWords[0]}"); } else if (stateMachine == State.BuryingCorpse) { switch (step) { case 2: return("Emote starts digging a grave for the corpse."); case 4: return("Emote places the body in the grave."); case 6: step = 0; return("Say And stay there this time."); default: return("Wait"); } } return(""); } } } } return(command); }
private IResult BuildItem(INonPlayerCharacter craftsman, IMobileObject performer, Equipment.AvalableItemPosition position, int level, string keyword, string sentenceDescription, string shortDescription, string lookDescription, string examineDescription, IEquipment equipment) { IResult result = null; result = CheckMoney(craftsman, performer, level, equipment); if (result != null) { return(result); } equipment.ItemPosition = position; equipment.KeyWords.Add(keyword); equipment.SentenceDescription = sentenceDescription; equipment.ShortDescription = shortDescription; equipment.LookDescription = lookDescription; equipment.ExamineDescription = examineDescription; equipment.FinishLoad(); DateTime completionDate = DateTime.UtcNow.AddMinutes(equipment.Level); //make it take 1 hour game for each level IGameDateTime gameDateTime = GlobalReference.GlobalValues.GameDateTime.GetDateTime(completionDate); craftsman.EnqueueCommand($"Tell {performer.KeyWords[0]} I will have this finished for you on {gameDateTime}."); result = new Result("", false); return(result); }
public string Process(INonPlayerCharacter npc, string command) { if (command == null) { if (npc.FollowTarget == null) { if (npc.Room.Zone == 16 && npc.Room.Id == 7) //don't start following in the room with the goblin chief { return(command); } bool guardFound = false; foreach (INonPlayerCharacter nonPlayerCharacter in npc.Room.NonPlayerCharacters) { if (nonPlayerCharacter.Zone == npc.Zone && nonPlayerCharacter.Id == 11) { guardFound = true; break; } } if (!guardFound) { if (npc.Room.PlayerCharacters.Count > 0) { npc.EnqueueCommand($"Follow {npc.Room.PlayerCharacters[0].KeyWords[0]}"); } } } } return(command); }
private static void EnqueueWait(INonPlayerCharacter npc, int times) { for (int i = 0; i < times; i++) { npc.EnqueueCommand("Wait"); } }
public string Process(INonPlayerCharacter npc, string command) { if (command == null) { foreach (INonPlayerCharacter otherNpc in npc.Room.NonPlayerCharacters) { if (otherNpc.Zone == 23 && otherNpc.Id == 10) //chief daughter info { if (otherNpc.FollowTarget != null) //don't keep giving the reward over and over { npc.EnqueueCommand("say You have brought my daughter back to me. I am most grateful."); npc.EnqueueCommand("say Please accept this gift as a reward."); //generate a reward; int level = GlobalReference.GlobalValues.Random.Next(18, 22); int bonus = GlobalReference.GlobalValues.Random.Next(4); IEquipment equipment = GlobalReference.GlobalValues.RandomDropGenerator.GenerateRandomEquipment(level, level + bonus); npc.EnqueueCommand($"say Servant, fetch me my best {equipment.KeyWords[0]} for our hero."); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Wait"); npc.Items.Add(equipment); npc.EnqueueCommand($"say Please accept this {equipment.KeyWords[0]} as a reward for rescuing my daughter."); npc.EnqueueCommand($"Give {equipment.KeyWords[0]} {otherNpc.FollowTarget.KeyWords[0]}"); otherNpc.FollowTarget = null; //make daughter stop flowing } } } } return(command); }
private IResult PerformRecall(IMobileObject performer) { if (performer.RecallPoint != null) { IRoom currentRoom = performer.Room; if (currentRoom.Attributes.Contains(Room.Room.RoomAttribute.NoRecall)) { return(new Result(false, "You try to recall but your body is held in place.")); } IRoom targetRoom = null; try { targetRoom = GlobalReference.GlobalValues.World.Zones[performer.RecallPoint.Zone].Rooms[performer.RecallPoint.Id]; } catch { } if (targetRoom != null) { IPlayerCharacter pc = performer as IPlayerCharacter; if (pc != null) { currentRoom.RemoveMobileObjectFromRoom(pc); targetRoom.AddMobileObjectToRoom(pc); pc.Room = targetRoom; pc.EnqueueCommand("Look"); return(SuccesfulRecallResult); } else { INonPlayerCharacter npc = performer as INonPlayerCharacter; currentRoom.RemoveMobileObjectFromRoom(npc); targetRoom.AddMobileObjectToRoom(npc); npc.Room = targetRoom; npc.EnqueueCommand("Look"); return(SuccesfulRecallResult); } } else { return(new Result(false, "Invalid recall point defined.")); } } else { return(new Result(false, "No recall point defined.")); } }
public IResult Build(INonPlayerCharacter craftsman, IPlayerCharacter performer, AvalableItemPosition position, int level, string keyword, string sentenceDescription, string shortDescription, string lookDescription, string examineDescription, DamageType damageType = DamageType.Slash) { IResult result; IItem item = null; switch (position) { case Equipment.AvalableItemPosition.Held: IEquipment equipment = new Equipment(); result = BuildItem(craftsman, performer, position, level, keyword, sentenceDescription, shortDescription, lookDescription, examineDescription, equipment); item = equipment; break; case Equipment.AvalableItemPosition.Wield: IWeapon weapon = new Weapon(); result = BuildItem(craftsman, performer, position, level, keyword, sentenceDescription, shortDescription, lookDescription, examineDescription, weapon); IDamage damage = new Damage.Damage(GlobalReference.GlobalValues.DefaultValues.DiceForWeaponLevel(weapon.Level)); damage.Type = damageType; weapon.DamageList.Add(damage); item = weapon; break; case Equipment.AvalableItemPosition.NotWorn: craftsman.EnqueueCommand($"Tell {performer.KeyWords[0]} I can not build that."); result = new Result("", true); break; default: IArmor armor = new Armor(); result = BuildItem(craftsman, performer, position, level, keyword, sentenceDescription, shortDescription, lookDescription, examineDescription, armor); item = armor; break; } if (!result.AllowAnotherCommand) { ICraftsmanObject craftsmanObject = new CraftsmanObject(); craftsmanObject.CraftsmanId = new BaseObjectId(craftsman); craftsmanObject.CraftmanDescripition = craftsman.ShortDescription; craftsmanObject.Completion = DateTime.Now.AddMinutes(item.Level); //make it take 1 hour game for each level craftsmanObject.Item = item; performer.CraftsmanObjects.Add(craftsmanObject); } return(result); }
private void ProcessMobPersonality(IMobileObject mob) { INonPlayerCharacter npc = mob as INonPlayerCharacter; if (npc != null && npc.PossingMob == null) //don't process the npc personalities if possessed { string command = null; foreach (IPersonality personality in npc.Personalities) { command = personality.Process(npc, command); } if (command != null) { npc.EnqueueCommand(command); } } }
public string Process(INonPlayerCharacter npc, string command) { if (command != null) { return(command); } #region Combat if (npc.IsInCombat) { int howManyKingsGuards = GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "Queen's guard").Count; if (howManyKingsGuards < 4) { npc.EnqueueCommand("Say GUARDS!"); SummonQueensGuards(4 - howManyKingsGuards, npc.Room); } return("Flee"); } #endregion Combat if (!GreetedKing && npc.Room.Id == 21) { if (GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "king").Count > 0) { GreetedKing = true; return(GreetingForKing[GlobalReference.GlobalValues.Random.Next(GreetingForKing.Count)]); } } Step++; int hour = GlobalReference.GlobalValues.GameDateTime.GameDateTime.Hour; if (hour < 13) { return(DayTimeThings(npc)); //return NightTimeThings(npc); } else { return(NightTimeThings(npc)); } }
public IResult PerformCommand(IMobileObject performer, ICommand command) { IResult result = base.PerfomCommand(performer, command); if (result != null) { return(result); } if (!(performer is IPlayerCharacter pc)) { return(new Result("Only player characters can have craftsman craft items.", true)); } INonPlayerCharacter craftsman = null; ICraftsman craftsmanPersonality = null; FindCraftsman(performer, ref craftsman, ref craftsmanPersonality); if (craftsman == null) { return(new Result("There is no craftsman to make anything for you.", true)); } if (command.Parameters.Count < 7) { return(new Result("Please provide all the parameters needed for the craftsman to make your item.", true)); } try { AvalableItemPosition position = GetPosition(command.Parameters[0].ParameterValue); if (position == AvalableItemPosition.Wield && command.Parameters.Count < 8) { return(new Result("Damage type is required for weapons.", true)); } int level = int.Parse(command.Parameters[1].ParameterValue); string keyword = command.Parameters[2].ParameterValue; string sentenceDescription = command.Parameters[3].ParameterValue; string shortDescription = command.Parameters[4].ParameterValue; string lookDescription = command.Parameters[5].ParameterValue; string examineDescription = command.Parameters[6].ParameterValue; DamageType damageType = DamageType.Acid; if (position == AvalableItemPosition.Wield) { damageType = GetDamageType(command.Parameters[7].ParameterValue); } if (level > craftsman.Level) { craftsman.EnqueueCommand($"Tell {performer.KeyWords[0]} That is above my skill level. You will need to find someone a higher level to craft such an item."); return(new Result(null, true)); } return(craftsmanPersonality.Build(craftsman, pc, position, level, keyword, sentenceDescription, shortDescription, lookDescription, examineDescription, damageType)); } catch (Exception ex) { if (ex is ArgumentException) { return(new Result(ex.Message, true)); } else { return(new Result("Please verify all parameters and try again.", true)); } } }
private string NightTimeThings(INonPlayerCharacter npc) { if (npc.Room.Id == 20) { string message = null; StateMachine = State.GotoBalcony; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>King says Court is closed for the day. Please come back tomorrow.</Communication>") { npc.EnqueueCommand("Say Its about time."); return("West"); } } if (GlobalReference.GlobalValues.GameDateTime.GameDateTime.Hour == 14) { npc.EnqueueCommand("Say Court is closed for the day. Please come back tomorrow."); return("West"); } } if (StateMachine == State.GotoBalcony) { if (npc.Room.Zone == 24 && npc.Room.Id == 22) { Step = 0; return("North"); } if (GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "King").Count > 0) { StateMachine = State.SpendTimeWithKing; Step = 0; return("Say Hello dear."); } } else if (StateMachine == State.SpendTimeWithKing) { if (Step % 5 == 0) { string message = null; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>King says Hello my beautify Queen.</Communication>") { return("Say I wish we could just leave this all behind."); } else if (message == "<Communication>King says That sounds nice. We should take a trip to the country to get away for a while.</Communication>") { return("Say A trip to the country sounds great We can goto the villa."); } else if (message == "<Communication>King says Lets plan to do this when the weather gets a little nicer.</Communication>") { return("Say Agreed."); } else if (message == "<Communication>King says Good night my love.</Communication>") { StateMachine = State.Bath; Step = 0; return("Say Goodnight my dear."); } } } } else if (StateMachine == State.Bath) { if (npc.Room.Zone == 24 && npc.Room.Id == 23) { return("South"); } else if (npc.Room.Zone == 24 && npc.Room.Id == 22) { return("South"); } else if (npc.Room.Zone == 24 && npc.Room.Id == 24) { if (Step % 5 == 0) { StateMachine = State.Undress; Step = 0; npc.LookDescription = "The Queen's hair falls gently down the back of her naked figure."; return("Emote removes her dress."); } } } else if (StateMachine == State.Undress) { if (Step % 5 == 0) { StateMachine = State.InTub; npc.LookDescription = "The Queen relaxes in the tub almost floating with only her head above the water."; return("Emote climbs into bath tub."); } } else if (StateMachine == State.InTub) { if (GlobalReference.GlobalValues.GameDateTime.GameDateTime.Hour == 20) { StateMachine = State.GetDress; Step = 0; npc.LookDescription = "The Queen's hair falls gently down the back of her naked figure."; return("Emote slowly rises out of the tub."); } } else if (StateMachine == State.GetDress) { if (Step % 5 == 0) { StateMachine = State.GotoSleep; npc.LookDescription = "The Queen is dressed in her white sleep gown."; return("Emote puts on her night gown."); } } else if (StateMachine == State.GotoSleep) { if (Step % 5 == 0) { if (npc.Room.Zone == 24 && npc.Room.Id == 24) { return("North"); } else if (npc.Room.Zone == 24 && npc.Room.Id == 22) { return("Sleep"); } } } return(null); }
public string Process(INonPlayerCharacter npc, string command) { if (command != null) { return(command); } if (npc.IsInCombat) { return(null); } Step++; if (StateMachine == State.Wait) { string message = null; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>King says Servant, bring me my meal.</Communication>") { npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Emote bows."); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Say Your Honorable Majestic Majesty Graciousness, what would you like to eat?"); StateMachine = State.AskedWhatWanted; } } } else if (StateMachine == State.AskedWhatWanted) { string message = null; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>King says Bring me hasenpfeffer.</Communication>") { npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Say Right away Your Honorable Royal Majestic Graciousness."); npc.EnqueueCommand("Wait"); StateMachine = State.KingToldHasenpfeffer; } } } else if (StateMachine == State.KingToldHasenpfeffer) { npc.EnqueueCommand("East"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Down"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("North"); npc.EnqueueCommand("Wait"); StateMachine = State.OnWayToKitchen; } else if (StateMachine == State.OnWayToKitchen) { if (npc.Room.Id == 19) { List <INonPlayerCharacter> nonPlayerCharacters = GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "cook"); if (nonPlayerCharacters.Count > 0) { StateMachine = State.AskCookForHasenpfeffer; return("Say The King wants hasenpfeffer to eat."); } else { StateMachine = State.EmptyKitchen; Step = 0; } } } else if (StateMachine == State.EmptyKitchen) { switch (Step) { case 1: return("Say Hello?"); case 5: return("Say Is there anyone here?"); case 10: return("Say Great how am I going to make hasenpfeffer?"); case 15: return("Emote scurries around the kitchen looking for something to give the King."); case 20: return("Emote scurries around the kitchen looking for something to give the King."); case 25: return("Say Ah Ha!"); case 30: return("Say This carrot will work."); case 35: npc.EnqueueCommand("Wait"); npc.EnqueueCommand("South"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Up"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("West"); StateMachine = State.GiveToKingCarrot; break; } } else if (StateMachine == State.AskCookForHasenpfeffer) { string message = null; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>Cook says here you go. Hasenpfeffer for the King.</Communication>") { npc.EnqueueCommand("Wait"); npc.EnqueueCommand("South"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("Up"); npc.EnqueueCommand("Wait"); npc.EnqueueCommand("West"); StateMachine = State.GiveToKingHasenpfeffer; } } } else if (StateMachine == State.GiveToKingHasenpfeffer) { if (npc.Room.Id == 21 && GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "King").Count > 0) { StateMachine = State.Wait; return("Bon appetit Most Gracious Majesty."); } } else if (StateMachine == State.GiveToKingCarrot) { if (npc.Room.Id == 21 && GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "King").Count > 0) { StateMachine = State.Wait; return("Your hasenpfeffer Your Magisty."); } } return(null); }
private string CheckForTrigger(INonPlayerCharacter npc) { string message; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>kings servant says The king wants hasenpfeffer to eat.</Communication>") { List <INonPlayerCharacter> nonPlayerCharacters = new List <INonPlayerCharacter>(npc.Room.NonPlayerCharacters); for (int i = 0; i < nonPlayerCharacters.Count; i++) { if (nonPlayerCharacters[i] == npc) { switch (cookId) { case 0: npc.EnqueueCommand("Say Right away."); EnqueueWait(npc, 2); npc.EnqueueCommand("Emote begins to cut up a rabbit."); EnqueueWait(npc, 5); npc.EnqueueCommand("Emote puts the rabbit in the pot."); break; case 1: npc.EnqueueCommand("Say As the king wishes."); EnqueueWait(npc, 2); npc.EnqueueCommand("Emote begins to cut up a potatoes."); EnqueueWait(npc, 3); npc.EnqueueCommand("Emote puts the potatoes in the pot."); break; case 2: npc.EnqueueCommand("Say Sure."); EnqueueWait(npc, 2); npc.EnqueueCommand("Emote begins to cut up a carrots."); EnqueueWait(npc, 4); npc.EnqueueCommand("Emote puts the carrots in the pot."); break; case 3: npc.EnqueueCommand("Say As the king wishes."); EnqueueWait(npc, 2); npc.EnqueueCommand("Emote stokes the cooking fire."); EnqueueWait(npc, 4); npc.EnqueueCommand("Emote stirs the pot."); EnqueueWait(npc, 4); npc.EnqueueCommand("Emote stirs the pot."); EnqueueWait(npc, 4); npc.EnqueueCommand("Emote stirs the pot."); EnqueueWait(npc, 4); npc.EnqueueCommand("Emote stirs the pot."); EnqueueWait(npc, 2); npc.EnqueueCommand("Say here you go. Hasenpfeffer for the king."); break; } break; } } } } return(message); }
private string NightTimeThings(INonPlayerCharacter npc) { if (npc.Room.Id == 21) { npc.EnqueueCommand("Say Court is closed for the day. Please come back tomorrow."); StateMachine = State.SpendTimeWithQueen; return("West"); } if (npc.Room.Id != 21 && npc.Room.Zone == 24) { if (npc.Room.PlayerCharacters.Count > 0) { foreach (IPlayerCharacter pc in npc.Room.PlayerCharacters) { if (GlobalReference.GlobalValues.CanMobDoSomething.SeeObject(npc, pc)) { int howManyKingsGuards = GlobalReference.GlobalValues.FindObjects.FindNpcInRoom(npc.Room, "King's guard").Count; if (howManyKingsGuards < 4) { SummonKingsGuards(4 - howManyKingsGuards, npc.Room); return("Say GUARDS!"); } } } } } if (StateMachine == State.SpendTimeWithQueen) { if (npc.Room.Id == 22) { Step = 0; return("North"); } if (Step % 5 == 0) { string message = null; while ((message = npc.DequeueMessage()) != null) { if (message == "<Communication>Queen says Hello dear.</Communication>") { return("Say Hello my beautify queen."); } else if (message == "<Communication>Queen says I wish we could just leave this all behind.</Communication>") { return("Say That sounds nice. We should take a trip to the country to get away for a while."); } else if (message == "<Communication>Queen says A trip to the country sounds great We can goto the villa.</Communication>") { return("Say Lets plan to do this when the weather gets a little nicer."); } else if (message == "<Communication>Queen says Agreed.</Communication>") { return("Say Good night my love."); } else if (message == "<Communication>Queen says Goodnight my dear.</Communication>") { StateMachine = State.Sleep; return("South"); } } } } else if (StateMachine == State.Sleep) { if (npc.Room.Zone == 24 && npc.Room.Id == 14) { if (npc.Position != MobileObject.CharacterPosition.Sleep) { return("Sleep"); } } } return(null); }