public static void AtStartup(RMUD.RuleEngine GlobalRules) { Core.StandardMessage("not useable", "I don't know what I would do with that."); GlobalRules.DeclareCheckRuleBook<MudObject, MudObject>("can use?", "[Actor, Item] : Can the actor use the item?", "actor", "item"); GlobalRules.DeclarePerformRuleBook<MudObject, MudObject>("used", "[Actor, Item] : Handle the actor using the item.", "actor", "item"); GlobalRules.Check<MudObject, MudObject>("can use?") .When((actor, item) => !item.GetBooleanProperty("useable?")) .Do((a, b) => { MudObject.SendMessage(a, "@not useable"); return SharpRuleEngine.CheckResult.Disallow; }) .Name("Can't use the unuseable rule."); GlobalRules.Check<MudObject, MudObject>("can use?") .Do((a, b) => SharpRuleEngine.CheckResult.Allow) .Name("Default go ahead and use it rule."); GlobalRules.Perform<MudObject, MudObject>("used").Do((actor, target) => { MudObject.SendMessage(actor, "It doesn't do anything."); return SharpRuleEngine.PerformResult.Continue; }).Name("Default report using rule."); GlobalRules.Check<MudObject, MudObject>("can use?").First.Do((actor, item) => MudObject.CheckIsVisibleTo(actor, item)).Name("Item must be visible rule."); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { ConversationModule.Settings.ListDiscussedTopics = false; ConversationModule.Settings.AllowRepeats = false; RMUD.Core.OverrideMessage("empty handed", ""); RMUD.Core.OverrideMessage("convo topic prompt", "You could ask <l0>."); GlobalRules.Perform<Player>("list topics") .When(player => SuppressTopics) .Do(player => RMUD.PerformResult.Stop); GlobalRules.Perform<Player>("singleplayer game started") .First .Do((actor) => { //BlockingConversation = true; //RMUD.MudObject.SendMessage(actor, "Sal? Sal? Can you hear me?"); //actor.SetProperty("interlocutor", RMUD.MudObject.GetObject("DanConversation0")); //RMUD.Core.EnqueuActorCommand(actor, "topics"); SwitchPlayerCharacter(RMUD.MudObject.GetObject("Areas.Prologue.Player") as RMUD.Player); RMUD.MudObject.Move(Player, RMUD.MudObject.GetObject("Areas.Lighthouse.Base")); RMUD.Core.EnqueuActorCommand(Player, "look"); //Player.SetProperty("interlocutor", RMUD.MudObject.GetObject("Areas.Prologue.Henrico")); //RMUD.Core.EnqueuActorCommand(Player, "topics"); //BlockingConversation = true; return RMUD.PerformResult.Stop; }); }
private static int FindSymbol(RMUD.Room Location) { var spacer = Location.Short.LastIndexOf('-'); if (spacer > 0 && spacer < Location.Short.Length - 2) return Location.Short.ToUpper()[spacer + 2]; else return Location.Short.ToUpper()[0]; }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { RMUD.Core.DefaultParser.AddCommand(RMUD.CommandFactory.KeyWord("BOUNCE")) .ProceduralRule((match, actor) => { SendMessage(actor, "Database defined commands appear to work."); return RMUD.PerformResult.Continue; }); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform<RMUD.PossibleMatch, RMUD.Actor>("before command") .When((m, a) => BlockingConversation == true) .Do((match, actor) => { var command = match["COMMAND"] as RMUD.CommandEntry; if (command.IsNamed("ASK") || command.IsNamed("HELP") || command.IsNamed("TOPICS")) return RMUD.PerformResult.Continue; RMUD.MudObject.SendMessage(actor, "Sal, I really need to talk about this."); RMUD.Core.EnqueuActorCommand(actor, "TOPICS"); return RMUD.PerformResult.Stop; }) .Name("Can only converse during a blocking conversation rule."); GlobalRules.Perform<Player, RMUD.MudObject, ConversationModule.Topic>("discuss topic") .Do((actor, npc, topic) => { topic.SetProperty("discussed", true); return RMUD.PerformResult.Continue; }) .Name("Mark topic discussed rule."); GlobalRules.Perform<Player>("list topics") .When(player => SuppressTopics) .Do(player => RMUD.PerformResult.Stop); GlobalRules.Perform<Player>("list topics") .Do(player => { var npc = player.GetProperty<RMUD.NPC>("interlocutor"); var availableTopics = npc.GetPropertyOrDefault<List<RMUD.MudObject>>("conversation-topics", new List<RMUD.MudObject>()).Where(topic => GlobalRules.ConsiderValueRule<bool>("topic available?", player, npc, topic)); if (availableTopics.Count() == 0) BlockingConversation = false; return RMUD.PerformResult.Continue; }) .Name("Unblock game if no available topics rule."); GlobalRules.Perform<Player>("singleplayer game started") .First .Do((actor) => { //BlockingConversation = true; //RMUD.MudObject.SendMessage(actor, "Sal? Sal? Can you hear me?"); //actor.SetProperty("interlocutor", RMUD.MudObject.GetObject("DanConversation0")); //RMUD.Core.EnqueuActorCommand(actor, "topics"); RMUD.MudObject.Move(actor, RMUD.MudObject.GetObject("Start")); RMUD.Core.EnqueuActorCommand(actor, "look"); return RMUD.PerformResult.Stop; }); }
private static void MapLocation(int[,] MapGrid, Dictionary<int, String> RoomLegend, int X, int Y, RMUD.Room Location, int Symbol) { if (X < 1 || X >= MapWidth - 1 || Y < 1 || Y >= MapHeight - 1) return; if (MapGrid[X, Y] != ' ') return; if (Symbol == ' ') Symbol = FindSymbol(Location); RoomLegend.Upsert(Symbol, Location.Short); PlaceSymbol(MapGrid, X, Y, Symbol); PlaceSymbol(MapGrid, X - 2, Y - 1, '+'); PlaceSymbol(MapGrid, X - 1, Y - 1, '-'); PlaceSymbol(MapGrid, X - 0, Y - 1, '-'); PlaceSymbol(MapGrid, X + 1, Y - 1, '-'); PlaceSymbol(MapGrid, X + 2, Y - 1, '+'); PlaceSymbol(MapGrid, X + 2, Y, '|'); PlaceSymbol(MapGrid, X - 2, Y, '|'); PlaceSymbol(MapGrid, X - 2, Y + 1, '+'); PlaceSymbol(MapGrid, X - 1, Y + 1, '-'); PlaceSymbol(MapGrid, X - 0, Y + 1, '-'); PlaceSymbol(MapGrid, X + 1, Y + 1, '-'); PlaceSymbol(MapGrid, X + 2, Y + 1, '+'); foreach (var link in Location.EnumerateObjects().Where(t => t.HasProperty("link direction"))) { var destinationName = link.GetProperty<string>("link destination"); var destination = MudObject.GetObject(destinationName) as RMUD.Room; var direction = link.GetPropertyOrDefault<RMUD.Direction>("link direction", RMUD.Direction.NORTH); if (direction == Direction.UP) { PlaceSymbol(MapGrid, X + 1, Y - 2, ':'); PlaceSymbol(MapGrid, X + 1, Y - 3, FindSymbol(destination)); } else if (direction == Direction.DOWN) { PlaceSymbol(MapGrid, X - 1, Y + 2, ':'); PlaceSymbol(MapGrid, X - 1, Y + 3, FindSymbol(destination)); } else { var directionVector = RMUD.Link.GetAsVector(direction); PlaceEdge(MapGrid, X + directionVector.X * 3, Y + directionVector.Y * 2, direction); //if (destination.RoomType == Location.RoomType) MapLocation(MapGrid, RoomLegend, X + (directionVector.X * 7), Y + (directionVector.Y * 5), destination, ' '); } } }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform<RMUD.MudObject, Room>("describe") .Do((viewer, item) => { var auto = RMUD.Core.ExecutingCommand.ValueOrDefault("AUTO", false); if (item.TimesViewed > 0 && auto) RMUD.MudObject.SendMessage(viewer, item.BriefDescription); else RMUD.MudObject.SendMessage(viewer, item.Long); item.TimesViewed += 1; return SharpRuleEngine.PerformResult.Stop; }).Name("Choose brief or long description rule."); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { OverrideMessages(); GlobalRules.Perform<Player>("singleplayer game started") .First .Do((actor) => { // Don't list the things an actor is holding. This gets rid of all the spurious 'is empty handed' messages. GlobalRules.DeleteRule("describe", "list-actor-held-items-rule"); Scenes.Opening.OpeningScene.Start(); return SharpRuleEngine.PerformResult.Stop; }); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform<MudObject>("enumerate-stats") .Do((actor) => { MudObject.SendMessage(actor, "CLIENTS"); return PerformResult.Continue; }); GlobalRules.Perform<MudObject, String>("stats") .When((actor, type) => type == "CLIENTS") .Do((actor, type) => { MudObject.SendMessage(actor, "~~ CLIENTS ~~"); foreach (var client in Clients.ConnectedClients) if (client is NetworkClient) MudObject.SendMessage(actor, (client as NetworkClient).ConnectionDescription + (client.Player == null ? "" : (" - " + client.Player.Short))); else MudObject.SendMessage(actor, "local " + (client.Player == null ? "" : (" - " + client.Player.Short))); return PerformResult.Stop; }); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { // Heavy things can be picked up, but not carried around. Core.StandardMessage("cant carry heavy thing", "^<the0> is too heavy to carry around."); GlobalRules.Check<MudObject, MudObject>("can go?") .When((actor, link) => HasHeavyThing(actor)) .Do((actor, link) => { MudObject.SendMessage(actor, "@cant carry heavy thing", FirstHeavyThing(actor)); return CheckResult.Disallow; }) .Name("Can't carry around heavy things rule."); GlobalRules.Check<MudObject, MudObject, MudObject>("can push direction?") .When((actor, subject, link) => HasHeavyThing(actor)) .Do((actor, subject, link) => { MudObject.SendMessage(actor, "@cant carry heavy thing", FirstHeavyThing(actor)); return CheckResult.Disallow; }) .Name("Can't carry around heavy things while pushing rule."); }
public static void StartConversation(RMUD.Actor Actor, RMUD.MudObject NPC) { if (FirstConversation) { FirstConversation = false; RMUD.MudObject.SendMessage(Actor, "\n[You've entered into a conversation. During a conversation, you will be prompted with a list of possible topics. You can see the list again by entering the command 'topics'. You can enter into a conversation with any character at any time using 'greet <character>']"); } Actor.SetProperty("interlocutor", NPC); RMUD.MudObject.SendMessage(Actor, "\n"); RMUD.Core.EnqueuActorCommand(Actor, "topics"); }
public static void SwitchPlayerCharacter(RMUD.Player NewCharacter) { Driver.SwitchPlayerCharacter(NewCharacter); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { RMUD.Core.OverrideMessage("not here", "I don't think there's anything like that here."); RMUD.Core.OverrideMessage("gone", "That isn't here anymore."); RMUD.Core.OverrideMessage("dont have that", "I don't have that."); RMUD.Core.OverrideMessage("already have that", "I already have that."); RMUD.Core.OverrideMessage("does nothing", "I don't think that did anything."); RMUD.Core.OverrideMessage("nothing happens", "Doesn't look like anything happened."); RMUD.Core.OverrideMessage("unappreciated", "I'd really rather not."); RMUD.Core.OverrideMessage("already open", "It's open already."); RMUD.Core.OverrideMessage("already closed", "It's closed already."); RMUD.Core.OverrideMessage("close it first", "I think I should probably close it first."); RMUD.Core.OverrideMessage("wrong key", "I can't make this key work."); RMUD.Core.OverrideMessage("error locked", "I think it's locked."); RMUD.Core.OverrideMessage("you went", "Okay, I'm going <s0>."); RMUD.Core.OverrideMessage("you close", "It's closed now."); RMUD.Core.OverrideMessage("they close", "^<the0> closes <the1>."); RMUD.Core.OverrideMessage("you drop", "I put <the0> down."); RMUD.Core.OverrideMessage("they drop", "^<the0> drops <a1>."); RMUD.Core.OverrideMessage("is open", "^<the0> is open."); RMUD.Core.OverrideMessage("is closed", "^<the0> is closed."); RMUD.Core.OverrideMessage("describe on", "There's <l1> on <the0>."); RMUD.Core.OverrideMessage("describe in", "Inside <the0> there is <l1>."); RMUD.Core.OverrideMessage("unmatched cardinal", "I don't know what way that is."); RMUD.Core.OverrideMessage("go to null link", "I don't see how I can go that way."); RMUD.Core.OverrideMessage("go to closed door", "Uh, the door is closed."); RMUD.Core.OverrideMessage("they went", "^<the0> went <s1>."); RMUD.Core.OverrideMessage("bad link", "Something is wrong with that direction. I don't know what."); RMUD.Core.OverrideMessage("they arrive", "^<the0> arrives <s1>."); RMUD.Core.OverrideMessage("nude", "You are naked."); RMUD.Core.OverrideMessage("wearing", "You are wearing.."); RMUD.Core.OverrideMessage("empty handed", "I have nothing."); RMUD.Core.OverrideMessage("carrying", "I've got.."); RMUD.Core.OverrideMessage("not lockable", "I don't think that can be locked."); RMUD.Core.OverrideMessage("you lock", "Okay, <the0> is locked."); RMUD.Core.OverrideMessage("they lock", "^<the0> locks <the1> with <the2>."); RMUD.Core.OverrideMessage("nowhere", "You aren't anywhere."); RMUD.Core.OverrideMessage("dark", "It's so dark I can't see anything."); RMUD.Core.OverrideMessage("also here", "I also see <l0>."); RMUD.Core.OverrideMessage("on which", "(on which is <l0>)"); RMUD.Core.OverrideMessage("obvious exits", "I could go"); RMUD.Core.OverrideMessage("through", "through <the0>"); RMUD.Core.OverrideMessage("to", "to <the0>"); RMUD.Core.OverrideMessage("cant look relloc", "I can't figure out how to look <s0> that."); RMUD.Core.OverrideMessage("is closed error", "^<the0> is closed."); RMUD.Core.OverrideMessage("relloc it is", "^<s0> <the1> is.."); RMUD.Core.OverrideMessage("nothing relloc it", "I don't see anything <s0> <the1>."); RMUD.Core.OverrideMessage("not openable", "I don't know how I would open that."); RMUD.Core.OverrideMessage("you open", "Okay, <the0> is open."); RMUD.Core.OverrideMessage("they open", "^<the0> opens <the1>."); RMUD.Core.OverrideMessage("cant put relloc", "I don't think I can put things <s0> that."); RMUD.Core.OverrideMessage("you put", "Okay, I put <the0> <s1> <the2>."); RMUD.Core.OverrideMessage("they put", "^<the0> puts <the1> <s2> <the3>."); RMUD.Core.OverrideMessage("say what", "Say what?"); RMUD.Core.OverrideMessage("emote what", "You exist. Actually this is an error message, but that's what you just told me to say."); RMUD.Core.OverrideMessage("speak", "^<the0> : \" < s1 > \""); RMUD.Core.OverrideMessage("emote", "^<the0> <s1>"); RMUD.Core.OverrideMessage("you take", "Okay, I've got <the0>."); RMUD.Core.OverrideMessage("they take", "^<the0> takes <the1>."); RMUD.Core.OverrideMessage("cant take people", "How would I take a person?"); RMUD.Core.OverrideMessage("cant take portals", "I think that's a bit impossible."); RMUD.Core.OverrideMessage("cant take scenery", "I don't think I can."); RMUD.Core.OverrideMessage("you unlock", "Okay, I unlocked <the0>."); RMUD.Core.OverrideMessage("they unlock", "^<the0> unlocks <the1> with <a2>."); RMUD.Core.OverrideMessage("help topics", "Available help topics"); RMUD.Core.OverrideMessage("no help topic", "There is no help available for that topic."); RMUD.Core.OverrideMessage("convo topic prompt", "You could <lor0>."); RMUD.Core.OverrideMessage("convo no topics", "There's nothing urgent to speak with Dan about."); }
private RMUD.LightingLevel EmittedLight(RMUD.MudObject Item) { var outside = GetObject(Outside) as RMUD.Room; if (outside != null) return outside.AmbientLighting - 1; return RMUD.LightingLevel.Dark; }
public void SwitchPlayerCharacter(RMUD.Player NewCharacter) { NewCharacter.Rank = 500; NewCharacter.CommandHandler = RMUD.Core.ParserCommandHandler; var client = Player.ConnectedClient; RMUD.Core.TiePlayerToClient(client, NewCharacter); Player = NewCharacter; }
public override void ForgetInstance(RMUD.MudObject Object) { }
public override void PersistInstance(RMUD.MudObject Object) { }
private static void PlaceEdge(int[,] MapGrid, int X, int Y, RMUD.Direction Direction) { if (X < 1 || X >= MapWidth - 1 || Y < 1 || Y >= MapHeight - 1) return; switch (Direction) { case RMUD.Direction.NORTH: case RMUD.Direction.SOUTH: MapGrid[X, Y] = '|'; break; case RMUD.Direction.EAST: case RMUD.Direction.WEST: MapGrid[X, Y] = '-'; break; case RMUD.Direction.NORTHEAST: case RMUD.Direction.SOUTHWEST: MapGrid[X, Y] = '/'; break; case RMUD.Direction.NORTHWEST: case RMUD.Direction.SOUTHEAST: MapGrid[X, Y] = '\\'; break; default: MapGrid[X, Y] = '*'; break; } }