/// <summary> /// Immortal command to kill a character in cold blood. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Slay(CharData ch, string[] str) { if( ch == null ) return; CharData realChar = ch.GetChar(); if (!realChar.Authorized("slay")) { return; } if (str.Length < 1 || String.IsNullOrEmpty(str[0])) { ch.SendText("Slay whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't even here.\r\n"); return; } if (ch == victim) { ch.SendText("You aren't powerful enough to kill yourself.\r\n"); return; } if (!victim.IsNPC() && victim.Level >= ch.Level) { ch.SendText("You failed.\r\n"); return; } if (str.Length > 1 && "immolate".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { SocketConnection.Act("Your &n&+rfi&+Rr&n&+re&+Rba&n&+rll&n turns $N into a blazing &n&+rinf&+Rer&+Yn&+Wo&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n releases a searing &n&+rfi&+Rr&n&+re&+Rba&n&+rll&n in your direction.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n points at $N, who bursts into a flaming &n&+rinf&+Rer&+Yn&+Wo&n.", ch, null, victim, SocketConnection.MessageTarget.room_vict); } else if (str.Length > 1 && "pounce".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase) && ch.GetTrust() >= Limits.LEVEL_OVERLORD) { SocketConnection.Act("Leaping upon $N with bared &+Wfangs&n, you tear open $S throat and toss the &+Lcorpse&n to the &n&+yground&n...", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("In a heartbeat, $n rips $s &+Wfangs&n through your throat! Your &+Rbl&n&+ro&+Ro&n&+rd&n sprays and pours to the &n&+yground&n as your life ends...", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("Leaping suddenly, $n sinks $s &+Wfangs&n into $N's throat. As &+Rbl&n&+ro&+Ro&n&+rd&n sprays and gushes to the &n&+yground&n, $n tosses $N's dying body away.", ch, null, victim, SocketConnection.MessageTarget.room_vict); } else if (str.Length > 1 && "shatter".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { SocketConnection.Act("You freeze $N with a glance and shatter the frozen &+Lcorpse&n into tiny &+Wsh&+Ca&+Wr&+Cds&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n freezes you with a glance and shatters your frozen body into tiny &+Wsh&+Ca&+Wr&+Cds&n.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n freezes $N with a simple look and shatters the frozen body into tiny &+Wsh&+Ca&+Wr&+Cds&n.", ch, null, victim, SocketConnection.MessageTarget.room_vict); } else if (str.Length > 1 && "slit".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase) && ch.GetTrust() >= Limits.LEVEL_OVERLORD) { SocketConnection.Act("You calmly &+Lslit&n $N's throat.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n reaches out with a clawwed finger and calmly &+Lslits&n your throat.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n calmly &+Lslits&n $N's throat.", ch, null, victim, SocketConnection.MessageTarget.room_vict); } else if (str.Length > 1 && "squeeze".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { SocketConnection.Act("You grasp $S head and squeeze it until it explodes in a bubble of &+Rbl&n&+ro&+Ro&n&+r&n!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n grasps your head and squeezes until your &+Wskull&n colapses!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n grasps $N's head and squeezes until it implodes!", ch, null, victim, SocketConnection.MessageTarget.room_vict); } else { SocketConnection.Act("You &+Lslay&n $M in cold &+Rbl&n&+ro&+Ro&n&+rd&n!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n &+Lslays&n you in cold &+Rbl&n&+ro&+Ro&n&+rd&n!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n &+Lslays&n $N in cold &+Rbl&n&+ro&+Ro&n&+rd&n!", ch, null, victim, SocketConnection.MessageTarget.room_vict); } Combat.KillingBlow(ch, victim); return; }
/// <summary> /// Returns a visibility value based on how well the looker can see the target. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <returns></returns> public static Visibility HowSee(CharData ch, CharData victim) { if (ch == null) { Log.Error("how_see called with null ch.", 0); return Visibility.invisible; } if (victim == null) { Log.Error("how_see called with null victim.", 0); return Visibility.invisible; } // Char almost dead, or asleep. if (ch.CurrentPosition <= Position.sleeping) { return Visibility.invisible; } // All mobiles cannot see wizinvised immortals. if (ch.IsNPC() && !victim.IsNPC() && victim.HasActionBit(PC.PLAYER_WIZINVIS)) { return Visibility.invisible; } // Handles Immortal Invis. if (!victim.IsNPC() && victim.HasActionBit(PC.PLAYER_WIZINVIS) && ch.GetTrust() < victim.Level) { return Visibility.invisible; } // Handles Immmortal sight. if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_GODMODE)) { return Visibility.visible; } // Handles blindness. if (ch.IsAffected(Affect.AFFECT_BLIND)) { return Visibility.invisible; } // Handles regular invisibility. if ((victim.IsAffected(Affect.AFFECT_INVISIBLE) || victim.IsAffected(Affect.AFFECT_MINOR_INVIS))) { if (ch.HasInnate(Race.RACE_DETECT_INVIS) || ch.IsAffected(Affect.AFFECT_DETECT_INVIS) || (ch.IsAffected(Affect.AFFECT_ELEM_SIGHT) && (victim.GetRace() == Race.RACE_AIR_ELE || victim.GetRace() == Race.RACE_WATER_ELE || victim.GetRace() == Race.RACE_FIRE_ELE || victim.GetRace() == Race.RACE_EARTH_ELE))) { if (victim.IsAffected(Affect.AFFECT_HIDE)) { if (ch.IsAffected(Affect.AFFECT_DETECT_HIDDEN)) { return Visibility.visible; } if (ch.HasInnate(Race.RACE_DETECT_HIDDEN) || ch.IsAffected(Affect.AFFECT_SENSE_LIFE)) { return Visibility.sense_hidden; } return Visibility.invisible; } return Visibility.visible; } } // Handles dark rooms. Added ultracheck. if (victim.InRoom.IsDark()) { if (ch.HasInnate(Race.RACE_ULTRAVISION) || ch.IsAffected(Affect.AFFECT_ULTRAVISION)) { return Visibility.visible; } if ((ch.HasInnate(Race.RACE_INFRAVISION) || ch.IsAffected(Affect.AFFECT_INFRAVISION)) && !victim.InRoom.HasFlag(RoomTemplate.ROOM_UNDERWATER)) { return Visibility.sense_infravision; } if (!(ch.HasInnate(Race.RACE_ULTRAVISION) || ch.IsAffected(Affect.AFFECT_ULTRAVISION))) { return Visibility.too_dark; } } // Handles hidden people. if (victim.IsAffected(Affect.AFFECT_HIDE)) { if (ch.IsAffected(Affect.AFFECT_DETECT_HIDDEN)) { return Visibility.visible; } if (ch.HasInnate(Race.RACE_DETECT_HIDDEN) || ch.IsAffected(Affect.AFFECT_SENSE_LIFE)) { return Visibility.sense_hidden; } return Visibility.invisible; } return Visibility.visible; }
/// <summary> /// Immortal command to make a player shut up permanently. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Silence(CharData ch, string[] str) { if( ch == null ) return; CharData victim; CharData realChar = ch.GetChar(); if (!realChar.Authorized("silence")) { return; } if (str.Length == 0) { ch.SendText("Silence whom?\r\n"); return; } if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust()) { ch.SendText("You failed.\r\n"); return; } if (victim.HasActionBit(PC.PLAYER_SILENCE)) { victim.RemoveActionBit(PC.PLAYER_SILENCE); victim.SendText("You can use channels again.\r\n"); ch.SendText("SILENCE removed.\r\n"); } else { victim.SetActionBit(PC.PLAYER_SILENCE); victim.SendText("You can't use channels!\r\n"); ch.SendText("SILENCE set.\r\n"); } return; }
/// <summary> /// Deny a player access to the game. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Deny(CharData ch, string[] str) { if( ch == null ) return; CharData realChar = ch.GetChar(); if (!realChar.Authorized("deny")) { return; } if (str.Length == 0) { ch.SendText("Deny whom?\r\n"); return; } CharData victim = ch.GetCharWorld(str[0]); if (victim == null) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust()) { ch.SendText("You failed.\r\n"); return; } victim.SetActionBit(PC.PLAYER_DENY); victim.SendText("You are denied access!\r\n"); ch.SendText("Done.\r\n"); if (victim.Level <= 1) { CommandType.Interpret(victim, "quit"); } return; }
/// <summary> /// Immortal command to paralyze a player. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Freeze(CharData ch, string[] str) { if( ch == null ) return; CharData victim; CharData realChar = ch.GetChar(); if (!realChar.Authorized("freeze")) { return; } if (str.Length == 0) { ch.SendText("Freeze whom?\r\n"); return; } if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } if (ch == victim && ch.HasActionBit(PC.PLAYER_FREEZE)) { ch.RemoveActionBit(PC.PLAYER_FREEZE); } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust()) { ch.SendText("You failed.\r\n"); return; } if (victim.HasActionBit(PC.PLAYER_FREEZE)) { victim.RemoveActionBit(PC.PLAYER_FREEZE); ch.SendText("FREEZE bit removed.\r\n"); victim.SendText("You can play again.\r\n"); } else { victim.SetActionBit(PC.PLAYER_FREEZE); ch.SendText("FREEZE bit set.\r\n"); victim.SendText("You can't do anything!\r\n"); } CharData.SavePlayer(victim); return; }
/// <summary> /// Immortal command to change a player's level. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Advance(CharData ch, string[] str) { if( ch == null ) return; CharData victim; string text; int level = 0; int iLevel = 0; CharData realChar = ch.GetChar(); if (!realChar.Authorized("advance")) { return; } if (str.Length < 2 || String.IsNullOrEmpty(str[0]) || String.IsNullOrEmpty(str[1]) || !MUDString.IsNumber(str[1])) { ch.SendText("Syntax: advance <char> <level>.\r\n"); return; } if (!(victim = ch.GetCharRoom(str[0]))) { ch.SendText("That player is not here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } Int32.TryParse(str[1], out level); if (level < 1 || level > Limits.MAX_LEVEL) { ch.SendText(String.Format("Advance within range 1 to {0}.\r\n", Limits.MAX_LEVEL)); return; } if (level > ch.GetTrust()) { ch.SendText("Limited to your trust level.\r\n"); return; } /* * Lower level: * Reset to level 1. * Then raise again. * Currently, an imp can lower another imp. */ if (level <= victim.Level) { ch.SendText("Lowering a player's level!\r\n"); victim.SendText("**** OOOOHHHHHHHHHH NNNNOOOO ****\r\n"); victim.Level = 1; // Max_hit should only be accessed for PERMENANT changes. victim.MaxHitpoints = 20; if (ch.CharacterClass.GainsMana) { victim.MaxMana = 50; // Mana bonuses for newbies. victim.MaxMana += (victim.GetCurrInt() / 10); victim.MaxMana += (victim.GetCurrWis() / 14); victim.MaxMana += (victim.GetCurrPow() / 7); } else { victim.MaxMana = 0; } victim.MaxMoves = 150; // removed resetting of skills. victim.Hitpoints = victim.GetMaxHit(); victim.CurrentMana = victim.MaxMana; victim.CurrentMoves = victim.MaxMoves; text = String.Format("{0} has been demoted to level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(victim, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); } else { ch.SendText("Raising a player's level!\r\n"); victim.SendText("**** OOOOHHHHHHHHHH YYYYEEEESSS ****\r\n"); text = String.Format("{0} has been advanced to level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(victim, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); } // Do not advance skills -- rerolling someone will auto-master // their skills with no effort from the player... so we advance // them with skills set to false -- Xangis for (iLevel = victim.Level; iLevel < level; iLevel++) { victim.AdvanceLevel(victim); } victim.ExperiencePoints = 1; victim.TrustLevel = 0; return; }
/// <summary> /// Make a clone of something. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Clone(CharData ch, string[] str) { if( ch == null ) return; string text; Object obj; CharData mob; if (str.Length == 0) { ch.SendText("Clone what?\r\n"); return; } if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "object")) { mob = null; obj = ch.GetObjHere(str[1]); if (obj == null) { ch.SendText("You don't see that here.\r\n"); return; } } else if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "mobile") || (!MUDString.IsPrefixOf(str[0], "character"))) { obj = null; mob = ch.GetCharRoom(str[1]); if (mob == null) { ch.SendText("You don't see that here.\r\n"); return; } } else { mob = ch.GetCharRoom(str[0]); obj = ch.GetObjHere(str[0]); if (mob == null && obj == null) { ch.SendText("You don't see that here.\r\n"); return; } } /* clone object */ if (obj != null) { Object clone = Database.CreateObject(obj.ObjIndexData, 0); Database.CloneObject(obj, ref clone); if (obj.CarriedBy != null) { clone.ObjToChar(ch); } else { clone.AddToRoom(ch.InRoom); } Object.RecursiveClone(ch, obj, clone); SocketConnection.Act("$n has created $p.", ch, clone, null, SocketConnection.MessageTarget.room); SocketConnection.Act("You clone $p.", ch, clone, null, SocketConnection.MessageTarget.character); text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text); return; } if (mob != null) { if (!mob.IsNPC()) { ch.SendText("You can only clone mobiles.\r\n"); return; } CharData clone = Database.CreateMobile(mob.MobileTemplate); Database.CloneMobile(mob, clone); foreach (Object obj2 in mob.Carrying) { Object newObj = Database.CreateObject(obj2.ObjIndexData, 0); Database.CloneObject(obj2, ref newObj); Object.RecursiveClone(ch, obj2, newObj); newObj.ObjToChar(clone); newObj.WearLocation = obj2.WearLocation; } clone.AddToRoom(ch.InRoom); SocketConnection.Act("$n has created $N.", ch, null, clone, SocketConnection.MessageTarget.room); SocketConnection.Act("You clone $N.", ch, null, clone, SocketConnection.MessageTarget.character); text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text); return; } }
/// <summary> /// Command to kill the MUD process. If that's not dangerous, I don't know what is. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void KillProcess(CharData ch, string[] str) { if( ch == null ) return; ch = ch.GetChar(); if( ch.GetTrust() < Limits.LEVEL_OVERLORD ) return; Log.Info("MUD Process terminated with KillProcess command by " + ch.Name); Environment.Exit(0); }
public static void LoadObject(CharData ch, string[] str) { if( ch == null ) return; ObjTemplate objTemplate; int level; CharData realChar = ch.GetChar(); if (str.Length < 1 || String.IsNullOrEmpty(str[0]) || !MUDString.IsNumber(str[0])) { ch.SendText("Syntax: load object <index number> <level>.\r\n"); return; } if (str.Length < 2 || String.IsNullOrEmpty(str[1])) { level = ch.GetTrust(); } else { if (!MUDString.IsNumber(str[1])) { ch.SendText("Syntax: load object <index number> <level>.\r\n"); return; } Int32.TryParse(str[1], out level); if (level < 0 || level > ch.GetTrust()) { ch.SendText("Limited to your trust level, which is " + ch.GetTrust() + ".\r\n"); return; } } int indexNumber; Int32.TryParse(str[0], out indexNumber); if (!(objTemplate = Database.GetObjTemplate(indexNumber))) { ch.SendText("No object has that index number.\r\n"); return; } Object obj = Database.CreateObject(objTemplate, level); if (obj.HasWearFlag(ObjTemplate.WEARABLE_CARRY)) { obj.ObjToChar(ch); } else { obj.AddToRoom(ch.InRoom); SocketConnection.Act("$n&n has created $p&n!", ch, obj, null, SocketConnection.MessageTarget.room); } ch.SendText("Done.\r\n"); string text = String.Format("{0} has loaded {1} at {2} [{3}]", ch.Name, obj.ShortDescription, ch.InRoom.Title, ch.InRoom.IndexNumber); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, realChar.GetTrust(), text); return; }
/// <summary> /// Called when a player quits or when camping preparations are complete. /// </summary> public static void Quit(CharData ch) { if (ch == null) { Log.Error("Quit: Called with null character."); return; } try { if (ch.HasActionBit(PC.PLAYER_CAMPING)) { ch.RemoveActionBit(PC.PLAYER_CAMPING); Act("You climb into your bedroll and leave the realm.", ch, null, null, MessageTarget.character); if (ch.Gender == MobTemplate.Sex.male) Act("$n&n climbs into his bedroll and leaves the realm.", ch, null, null, MessageTarget.room); else if (ch.Gender == MobTemplate.Sex.female) Act("$n&n climbs into her bedroll and leaves the realm.", ch, null, null, MessageTarget.room); else Act("$n&n climbs into its bedroll and leaves the realm.", ch, null, null, MessageTarget.room); string text = String.Format("{0} has camped out.", ch.Name); Log.Trace(text); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOGINS, ch.GetTrust(), text); } else { ch.SendText("You leave the realm.\r\n\r\n"); Act("$n&n has left the realm.", ch, null, null, MessageTarget.room); Log.Trace(String.Format("{0} has camped out.", ch.Name)); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOGINS, ch.GetTrust(), String.Format("{0} has camped out.", ch.Name)); } // I know we checked for position fighting, but I'm paranoid... if (ch.Fighting) { Combat.StopFighting(ch, true); } ch.DieFollower(ch.Name); Room room = null; if (ch.InRoom) { room = ch.InRoom; } ch.RemoveFromRoom(); if (room != null) { ch.InRoom = room; ((PC)ch).LastRentLocation = ch.InRoom.IndexNumber; } // Put them in the correct body if (ch && ch.Socket && ch.Socket.Original) { CommandType.Interpret(ch, "return"); } CharData.SavePlayer(ch); Database.CharList.Remove(ch); if (ch && ch.Socket) { ch.Socket.ShowScreen(Screen.MainMenuScreen); ch.Socket.ConnectionStatus = ConnectionState.menu; } } catch (Exception ex) { Log.Error("Error in SocketConnection.Quit: " + ex.ToString()); } return; }
public static void Hometown(CharData ch, string[] str) { if( ch == null ) return; if (ch == null) { Log.Error("Command.Hometown: No ch!", 0); return; } if (!ch.IsGuild() && !ch.IsImmortal()) { ch.SendText("You don't have the power to do this.\r\n"); return; } if (ch.IsNPC()) return; if (!ch.InRoom.HasFlag(RoomTemplate.ROOM_GUILDROOM)) { ch.SendText("You can't set your hometown here!\r\n"); return; } if (ch.CurrentPosition == Position.fighting || ch.Fighting) { ch.SendText("No way! You are fighting.\r\n"); return; } if (ch.CurrentPosition < Position.stunned) { ch.SendText("You're not &+RD&n&+rE&+RA&n&+rD&n yet.\r\n"); return; } string logBuf = String.Format("{0} is resetting their hometown to {1}.", ch.Name, ch.InRoom.IndexNumber); Log.Trace(logBuf); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOGINS, ch.GetTrust(), logBuf); // I can't see any reason why ch would not have an .in_room, but that // may just be shortsighted of me - Xangis if (!ch.InRoom) { Log.Error("Commandhometown: ch not in a room!", 0); return; } // Put them in the correct body if (ch.Socket && ch.Socket.Original) { CommandType.Interpret(ch, "return"); } ch.SendText("You Reset your hometown.\r\n"); ((PC)ch).CurrentHome = ch.InRoom.IndexNumber; CharData.SavePlayer(ch); return; }
/// <summary> /// True if char can see victim. /// /// This is only a straightford all-or-none vision checker. /// /// If you need more granularity, use Command.HowSee which returns an enum /// based on the level of visibility but otherwise functions similarly. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <returns></returns> public static bool CanSee( CharData ch, CharData victim ) { if( ch == null ) { Log.Error( "CharData.CanSee: called with null ch.", 0 ); return false; } if( victim == null ) { Log.Error( "CharData.CanSee: called with null victim.", 0 ); return false; } if( ch == victim ) { return true; } /* All mobiles cannot see wizinvised immorts */ if (ch.IsNPC() && !ch.IsNPC() && ch.HasActionBit(PC.PLAYER_WIZINVIS)) { return false; } if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_WIZINVIS) && ch.GetTrust() < ch.Level) { return false; } if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_GODMODE)) { return true; } if( ch.IsAffected( Affect.AFFECT_BLIND ) ) { return false; } if (ch.InRoom == null) { Log.Error("CanSee called by player " + ch.Name + " with null room."); return false; } if( ch.InRoom.IsDark() && !ch.HasInnate( Race.RACE_ULTRAVISION ) && !ch.IsAffected( Affect.AFFECT_ULTRAVISION ) && !ch.HasInnate( Race.RACE_INFRAVISION ) && !ch.IsAffected(Affect.AFFECT_INFRAVISION ) ) { return false; } if (ch.CurrentPosition == Position.dead) { return true; } if ((victim.IsAffected(Affect.AFFECT_INVISIBLE) || victim.IsAffected(Affect.AFFECT_MINOR_INVIS)) && !ch.HasInnate( Race.RACE_DETECT_INVIS ) && !ch.IsAffected(Affect.AFFECT_DETECT_INVIS ) && !(ch.IsAffected(Affect.AFFECT_ELEM_SIGHT) && ( ch.GetRace() == Race.RACE_AIR_ELE || ch.GetRace() == Race.RACE_WATER_ELE || ch.GetRace() == Race.RACE_FIRE_ELE || ch.GetRace() == Race.RACE_EARTH_ELE ) ) ) { return false; } if( victim.IsAffected( Affect.AFFECT_HIDE ) && !ch.HasInnate( Race.RACE_DETECT_HIDDEN ) && !ch.IsAffected( Affect.AFFECT_DETECT_HIDDEN ) && !ch.Fighting ) { return false; } return true; }
/// <summary> /// Show a character to another character. This is the abbreviated version used in "look room" /// </summary> /// <param name="victim"></param> /// <param name="ch"></param> public static void ShowCharacterToCharacterAbbreviated(CharData victim, CharData ch) { string text = String.Empty; if (!victim || !ch) { Log.Error("ShowCharacterToCharacter0(): null ch or victim.", 0); return; } if (victim.Rider && victim.Rider.InRoom == ch.InRoom) { return; } // If invis, show char invis symbol first. if (victim.IsAffected(Affect.AFFECT_INVISIBLE)) { text += "&+L*&n "; } // Show the player's description. if (((!ch.IsNPC() && victim.CurrentPosition == Position.standing) || (victim.IsNPC() && victim.MobileTemplate != null && victim.CurrentPosition == victim.MobileTemplate.DefaultPosition)) && (!String.IsNullOrEmpty(victim.FullDescription)) && !victim.Riding) { // Added long description does not have \r\n removed. We may want to. text += victim.Description + "&n"; } else { // Show the player's name. text += victim.ShowNameTo(ch, true) + "&n"; // Show the player's title. // Show the player's race, only if PC, and on the same side of the racewar or a god. if (!victim.IsNPC() && ((PC)victim).Title.Length > 0) { if (MUDString.StringsNotEqual(((PC)victim).Title, " &n") && (ch.IsNPC())) { text += ((PC)victim).Title; } if (victim.IsGuild() && (ch.IsNPC())) { text += " " + ((PC)victim).GuildMembership.WhoName; } if (!ch.IsRacewar(victim) || victim.IsImmortal() || ch.IsImmortal()) { text += " (" + Race.RaceList[victim.GetRace()].ColorName + ")"; } } // Show the player's condition. text += " is "; if (victim.CurrentPosition == Position.standing && victim.CanFly()) { text += "flying"; } else { text += Position.PositionString(victim.CurrentPosition); } text += " here"; if (victim.Fighting != null) { text += "&n fighting "; if (victim.Fighting == ch) { text += "&nyou!"; } else if (victim.InRoom == victim.Fighting.InRoom) { text += victim.Fighting.ShowNameTo(ch, false); } else { text += "&nsomeone who left??"; } } if (victim.Riding && victim.Riding.InRoom == victim.InRoom) { text += "&n, mounted on " + victim.Riding.ShowNameTo(ch, false); } text += "&n."; } if (victim.IsAffected(Affect.AFFECT_CASTING)) { text += "&n&+y (casting)&n"; } if (victim.IsAffected(Affect.AFFECT_MINOR_PARA)) { text += "&n (&+Yparalyzed)&n"; } if (!victim.IsNPC() && victim.HasActionBit(PC.PLAYER_WIZINVIS) && victim.GetTrust() <= ch.GetTrust()) { text += " &n&+g*&n"; } if (victim.IsAffected(Affect.AFFECT_HIDE) && (ch.IsAffected(Affect.AFFECT_DETECT_HIDDEN) || ch.HasInnate(Race.RACE_DETECT_HIDDEN))) { text += " &n(&+LHiding&n)"; } if (victim.IsAffected(Affect.AFFECT_CHARM) && ch.HasActionBit(PC.PLAYER_GODMODE)) { text += " &n(&n&+mCharmed&n)"; } if ((victim.IsAffected(Affect.AFFECT_PASS_DOOR) || victim.HasInnate(Race.RACE_PASSDOOR)) && ch.HasActionBit(PC.PLAYER_GODMODE)) { text += " &n(&+WTranslucent&n)"; } if ((victim.GetRace() == Race.RACE_UNDEAD || victim.GetRace() == Race.RACE_VAMPIRE) && (ch.IsAffected( Affect.AFFECT_DETECT_UNDEAD) || ch.HasActionBit(PC.PLAYER_GODMODE))) { text += " &n(&+WPale&n)"; } if (victim.IsAffected(Affect.AFFECT_FAERIE_FIRE)) { text += " &n(&n&+mFa&+Me&n&+mr&+Mie&+L Aura&n)"; } if (victim.IsEvil() && (ch.IsAffected(Affect.AFFECT_DETECT_EVIL) || ch.HasInnate(Race.RACE_DETECT_ALIGN) || ch.IsClass(CharClass.Names.paladin) || ch.IsClass(CharClass.Names.antipaladin))) { text += " &n(&+rBlood&+L Aura&n)"; } if (victim.IsGood() && (ch.IsAffected(Affect.AFFECT_DETECT_GOOD) || ch.HasInnate(Race.RACE_DETECT_ALIGN) || ch.IsClass(CharClass.Names.paladin) || ch.IsClass(CharClass.Names.antipaladin))) { text += " &n(&+CLight&+L Aura&n)"; } if (victim.IsAffected(Affect.AFFECT_SANCTUARY)) { text += " &n(&+WWhite&+L Aura&n)"; } if (!victim.IsNPC() && victim.HasActionBit(PC.PLAYER_AFK)) { text += " &n&+b(&+RAFK&n&+b)&n"; } if (!victim.IsNPC() && victim.HasActionBit(PC.PLAYER_BOTTING)) { text += " &n&+b(&+YBot&n&+b)&n"; } text += "\r\n"; ch.SendText(text); return; }
/// <summary> /// Shows a list of characters to the looker. This is used for displaying the mobs that are in a room. /// </summary> /// <param name="list"></param> /// <param name="ch"></param> public static void ShowCharacterToCharacter(List<CharData> list, CharData ch) { if (list.Count == 0) { return; } foreach (CharData listChar in list) { if (listChar == ch) continue; if (listChar.FlightLevel != ch.FlightLevel) continue; if (!listChar.IsNPC() && listChar.HasActionBit(PC.PLAYER_WIZINVIS) && ch.GetTrust() < listChar.GetTrust()) continue; Visibility sight = HowSee(ch, listChar); if (sight == Visibility.visible) { ShowCharacterToCharacterAbbreviated(listChar, ch); } else if (sight == Visibility.sense_infravision) { ch.SendText(String.Format("&+rYou see the red shape of a {0} living being here.&n\r\n", Race.SizeString(listChar.CurrentSize))); } else if (sight == Visibility.sense_hidden) { ch.SendText("&+LYou sense a lifeform nearby.&n\r\n"); } else if (sight == Visibility.invisible && (listChar.Riding) && HowSee(ch, listChar.Riding) != Visibility.invisible) { listChar.Riding.Rider = null; ShowCharacterToCharacterAbbreviated(listChar.Riding, ch); listChar.Riding.Rider = listChar.Riding; } } }
/// <summary> /// Spy on the input and output of a character. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Snoop(CharData ch, string[] str) { if( ch == null ) return; SocketConnection socket; CharData realChar = ch.GetChar(); if (!realChar.Authorized("snoop")) { return; } if (str.Length == 0) { ch.SendText("Snoop whom?\r\n"); return; } CharData victim = ch.GetCharWorld(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } if (!victim.Socket) { ch.SendText("No descriptor to snoop.\r\n"); return; } if (victim == ch) { ch.SendText("Cancelling all snoops.\r\n"); foreach (SocketConnection it in Database.SocketList) { socket = it; if (socket.SnoopBy == ch.Socket) { socket.SnoopBy = null; } } return; } if (victim.Socket.SnoopBy != null) { ch.SendText("Busy already.\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust() && MUDString.StringsNotEqual(ch.Name, "Xangis")) { ch.SendText("You failed.\r\n"); return; } if (ch.Socket) { for (socket = ch.Socket.SnoopBy; socket; socket = socket.SnoopBy) { if (socket.Character == victim || socket.Original == victim) { ch.SendText("No snoop loops.\r\n"); return; } } } victim.Socket.SnoopBy = ch.Socket; ch.SendText("Done.\r\n"); string text = String.Format("{0} is snooping {1}", ch.Name, victim.Name); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SNOOPS, realChar.GetTrust(), text); return; }
public static void NewPlayerLock(CharData ch, string[] str) { if( ch == null ) return; string buf; CharData realChar = ch.GetChar(); if (!realChar.Authorized("newlock")) return; if (Database.SystemData.NumlockLevel != 0 && ch.GetTrust() < Limits.LEVEL_GREATER_GOD) { ch.SendText("You may not change the current _numlockLevel setting\r\n"); buf = String.Format("Game numlocked to levels {0} and below.\r\n", Database.SystemData.NumlockLevel); ch.SendText(buf); return; } if (Database.SystemData.NumlockLevel != 0) { buf = String.Format("Game numlocked to levels {0} and below.\r\n", Database.SystemData.NumlockLevel); ch.SendText(buf); ch.SendText("Changing to: "); } Database.SystemData.NumlockLevel = 1; ch.SendText("Game locked to new characters.\r\n"); return; }
/// <summary> /// Player track command. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void TrackCommand(CharData ch, string[] str) { if( ch == null ) return; CharData victim; if (ch.IsAffected(Affect.AFFECT_TRACK)) { ch.SendText("You stop tracking.\r\n"); Combat.StopHunting(ch); ch.RemoveAffect(Affect.AFFECT_TRACK); return; } if (!ch.HasSkill("track")) { ch.SendText("You couldn't track an &+Lelephant&n in your own bedroom.\r\n"); return; } if (str.Length == 0) { ch.SendText("Whom are you trying to track?\r\n"); return; } if (ch.Riding) { ch.SendText("You can't sniff a trail mounted.\r\n"); return; } if (ch.FlightLevel != 0) { ch.SendText("You find tracks on the _ground_!\r\n"); return; } if (ch.InRoom.IsWater()) { ch.SendText("You can't track through water.\r\n"); return; } if (ch.CurrentPosition != Position.standing) { if (ch.CurrentPosition == Position.fighting) ch.SendText("You're too busy fighting .\r\n"); else ch.SendText("You must be standing to track!\r\n"); return; } /* only imps can hunt to different areas */ bool area = (ch.GetTrust() < Limits.LEVEL_OVERLORD); if (area) { victim = ch.GetCharInArea(str[0]); } else { victim = ch.GetCharWorld(str[0]); } if (!victim || (!victim.IsNPC() && (ch.IsRacewar(victim)) && !ch.IsImmortal())) { ch.SendText("You can't find a trail of anyone like that.\r\n"); return; } if (ch.InRoom == victim.InRoom) { SocketConnection.Act("You're already in $N&n's room!", ch, null, victim, SocketConnection.MessageTarget.character); return; } /* * Deduct some movement. */ if (ch.CurrentMoves > 2) { ch.CurrentMoves -= 3; } else { ch.SendText("You're too exhausted to hunt anyone!\r\n"); return; } SocketConnection.Act("$n carefully sniffs the air.", ch, null, null, SocketConnection.MessageTarget.room); ch.WaitState(Skill.SkillList["track"].Delay); Exit.Direction direction = Track.FindPath(ch.InRoom.IndexNumber, victim.InRoom.IndexNumber, ch, -40000, area); if (direction == Exit.Direction.invalid) { SocketConnection.Act("You can't sense $N&n's trail from here.", ch, null, victim, SocketConnection.MessageTarget.character); return; } /* * Give a random direction if the player misses the die roll. */ if ((ch.IsNPC() && MUDMath.NumberPercent() > 75) /* NPC @ 25% */ || (!ch.IsNPC() && MUDMath.NumberPercent() > /* PC @ norm */ ((PC)ch).SkillAptitude["track"])) { do { direction = Database.RandomDoor(); } while (!(ch.InRoom.ExitData[(int)direction]) || !(ch.InRoom.ExitData[(int)direction].TargetRoom)); } ch.PracticeSkill("track"); /* * Display the results of the search. */ ch.SetAffectBit(Affect.AFFECT_TRACK); string buf = String.Format("You sense $N&n's trail {0} from here...", direction.ToString()); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.character); if (ch.CurrentPosition == Position.standing) { ch.Move(direction); } Combat.StartHunting(ch, victim); return; }
/// <summary> /// Immortal command to take away a player's ability to emote. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void NoEmote(CharData ch, string[] str) { if( ch == null ) return; CharData victim; CharData realChar = ch.GetChar(); if (!realChar.Authorized("noemote")) return; if (str.Length == 0) { ch.SendText("NoEmote whom?\r\n"); return; } if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust()) { ch.SendText("You failed.\r\n"); return; } if (victim.HasActionBit(PC.PLAYER_NO_EMOTE)) { victim.RemoveActionBit(PC.PLAYER_NO_EMOTE); ch.SendText("NO_EMOTE removed.\r\n"); victim.SendText("You are now allowed to emote.\r\n"); } else { victim.SetActionBit(PC.PLAYER_NO_EMOTE); victim.SendText("You are no longer allowed to emote!\r\n"); ch.SendText("NO_EMOTE set.\r\n"); } return; }
public static void Trust(CharData ch, string[] str) { if( ch == null ) return; CharData victim; string arg1 = String.Empty; string arg2 = String.Empty; int level; CharData realChar = ch.GetChar(); if (!realChar.Authorized("trust")) { return; } if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2) || !MUDString.IsNumber(arg2)) { ch.SendText("Syntax: trust <char> <level>.\r\n"); return; } if (!(victim = ch.GetCharRoom(arg1))) { ch.SendText("That player is not here.\r\n"); return; } Int32.TryParse(arg2, out level); if (level < 1 || level > Limits.MAX_LEVEL) { ch.SendText(String.Format("Trust within range 1 to {0}.\r\n", Limits.MAX_LEVEL)); return; } if (level > ch.GetTrust()) { ch.SendText("Limited to your trust.\r\n"); return; } string text = String.Format("{0} has been trusted at level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); victim.TrustLevel = level; return; }
/// <summary> /// Leave the game at an inn. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Rent(CharData ch, string[] str) { if( ch == null ) return; Room room = null; CharData worldChar; if (ch.IsNPC()) return; if (!ch.InRoom || !ch.InRoom.HasFlag(Room.ROOM_INN)) { ch.SendText("You must be within an inn to rent.\r\n"); return; } if (ch.CurrentPosition == Position.fighting || ch.Fighting) { ch.SendText("No way! You are fighting.\r\n"); return; } if (ch.CurrentPosition < Position.stunned) { ch.SendText("You're not &+RD&n&+rE&+RA&n&+rD&n yet.\r\n"); return; } ch.SendText("The innkeeper grabs a &+Lkey&n from the &n&+yrack&n, and shows you to your room.\r\n\r\n"); SocketConnection.Act("$n&n has left the realm.", ch, null, null, SocketConnection.MessageTarget.room); Log.Trace(String.Format("{0} has rented.", ch.Name)); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOGINS, ch.GetTrust(), String.Format("{0} has rented.", ch.Name)); /* * After CharData.ExtractChar the ch is no longer valid * that is why we aren't extracting the character but rather * sending them to our version of the "menu". */ // I know we checked for position fighting, but I'm paranoid... if (ch.Fighting != null) { Combat.StopFighting(ch, true); } ch.DieFollower(ch.Name); // I can't see any reason why ch would not have an .in_room, but that // may just be shortsighted of me - Xangis if (ch.InRoom) { room = ch.InRoom; } ch.RemoveFromRoom(); if (room) { ch.InRoom = room; } // Put them in the correct body if (ch.Socket && ch.Socket.Original) { CommandType.Interpret(ch, "return"); } foreach (CharData it in Database.CharList) { worldChar = it; if (worldChar.ReplyTo == ch) { worldChar.ReplyTo = null; } } ch.RemoveActionBit(PC.PLAYER_CAMPING); ((PC)ch).LastRentLocation = ch.InRoom.IndexNumber; CharData.SavePlayer(ch); // Remove them from the character list. for( int i = Database.CharList.Count -1; i >= 0; --i ) { if (Database.CharList[i] == ch) { Database.CharList.RemoveAt(i); } } // ConnectionState.menu is when they enter // the game... this shows menu // before they enter the game ch.Socket.ShowScreen(Screen.MainMenuScreen); ch.Socket.ConnectionStatus = SocketConnection.ConnectionState.menu; return; }
/// <summary> /// Shows the available commands. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Commands(CharData ch, string[] str) { if( ch == null ) return; string buf = String.Empty; int col = 0; foreach (CommandType cmd in CommandType.CommandTable) { if (cmd.MinLevel < Limits.LEVEL_HERO && cmd.MinLevel <= ch.GetTrust() && cmd.Show) { buf += String.Format("{0} ", MUDString.PadStr(cmd.Name, 16)); // Format into 4 columns. if (++col % 4 == 0) { buf += "\r\n"; } } } if (col % 5 != 0) buf += "\r\n"; ch.SendText(buf); return; }
/// <summary> /// Change something on a mob or a player. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void SetMob(CharData ch, string[] str) { if( ch == null ) return; ch = ch.GetChar(); if (str.Length < 3) { ch.SendText("Syntax: set mob <victim> <field> <value>\r\n"); ch.SendText("or: set mob <victim> <string> <value>\r\n"); ch.SendText("\r\n"); ch.SendText("Field being one of:\r\n"); ch.SendText(" str int wis dex con agi cha pow luck size\r\n"); ch.SendText(" class hp mana move align wait height weight\r\n"); ch.SendText(" sex race level thirst hunger drunk full security\r\n"); ch.SendText(" copper silver gold platinum position exp faction\r\n"); ch.SendText(" resistant immune susceptible vulnerable\r\n"); ch.SendText("String being one of:\r\n"); ch.SendText(" name short long title spec guild rank\r\n"); return; } CharData victim; if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } /* * Snarf the value (which need not be numeric). */ int value; bool ok = Int32.TryParse(str[2], out value); if (!ok) { value = -1; } string text = String.Empty; /* * Set something. */ if ("strength".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Strength range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermStrength = value; ch.SendText("Ok.\r\n"); return; } if ("intelligence".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Intelligence range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermIntelligence = value; ch.SendText("Ok.\r\n"); return; } if ("wisdom".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Wisdom range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermWisdom = value; ch.SendText("Ok.\r\n"); return; } if ("dexterity".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Dexterity range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermDexterity = value; ch.SendText("Ok.\r\n"); return; } if ("constitution".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Constitution range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermConstitution = value; ch.SendText("Ok.\r\n"); return; } if ("agility".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Agility range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermAgility = value; ch.SendText("Ok.\r\n"); return; } if ("charisma".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Charisma range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermCharisma = value; ch.SendText("Ok.\r\n"); return; } if ("power".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Power range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermPower = value; ch.SendText("Ok.\r\n"); return; } if ("luck".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 1 || value > Limits.MAX_BASE_ATTRIBUTE) { text += "Luck range is 1 to " + Limits.MAX_BASE_ATTRIBUTE + ".\r\n"; ch.SendText(text); return; } victim.PermLuck = value; ch.SendText("Ok.\r\n"); return; } /* size */ if ("size".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { Race.Size newsize; int val; Int32.TryParse(str[2], out val); if (val == 0) newsize = StringLookup.SizeLookup(str[2]); else newsize = (Race.Size)val; if (newsize < 0 || newsize > Race.Size.none) { text += "Size range is from 0 to " + Race.MAX_SIZE + ".\r\n"; ch.SendText(text); return; } victim.CurrentSize = newsize; ch.SendText("Ok.\r\n"); return; } if ("position".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 0 || value > (int)Position.standing) { text += "Position range is from 0 to " + Position.standing + ".\r\n"; ch.SendText(text); return; } victim.CurrentPosition = value; ch.SendText("Ok.\r\n"); return; } if ("faction".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Can't set faction values on an NPC.\r\n"); return; } ch.SendText("Setting faction values isn't done yet.\r\n"); return; //if( value < Limits.MIN_FACTION || value > Limits.MAX_FACTION ) //{ // ch.SendText( String.Format( "Valid faction values range from {0} to {1}.\r\n", // Limits.MIN_FACTION, Limits.MAX_FACTION )); // return; //} } if ("class".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { CharClass.Names cclass = CharClass.ClassLookup(str[2]); if (cclass < 0 || (int)cclass >= CharClass.ClassList.Length) { int cval; if (Int32.TryParse(str[2], out cval)) { cclass = (CharClass.Names)cval; } } if (cclass < 0 || (int)cclass >= CharClass.ClassList.Length) { string buf4 = String.Format("Class range is 0 to {0}.\n", CharClass.ClassList.Length - 1); ch.SendText(buf4); return; } value = (int)cclass; SocketConnection.Act("You set $N&n's class to $t.", ch, CharClass.ClassList[value].Name, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("Your class is now $t.", ch, CharClass.ClassList[value].Name, victim, SocketConnection.MessageTarget.victim); victim.CharacterClass = CharClass.ClassList[value]; victim.CharClassNumber = value; ch.SendText("Ok.\r\n"); return; } if ("sex".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsAffected( Affect.AFFECT_CHANGE_SEX)) { ch.SendText("This person is affect by change sex.\r\n"); ch.SendText("Try again later.\r\n"); return; } if (value < 0 || value > 2) { ch.SendText("Sex range is 0 to 2.\r\n"); return; } victim.Gender = (MobTemplate.Sex)value; ch.SendText("Ok.\r\n"); return; } if ("race".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { Object wield; Object wield2; if (victim.IsAffected( Affect.AFFECT_POLYMORPH)) { ch.SendText("This person is affected by polymorph other.\r\n"); ch.SendText("Try again later.\r\n"); return; } int race = Race.RaceLookup(str[1]); if (race < 0 || race >= Race.RaceList.Length) Int32.TryParse(str[2], out race); if (race < 0 || race >= Race.RaceList.Length) { ch.SendText("Invalid race.\r\n"); return; } victim.SetPermRace(race); if ((wield = Object.GetEquipmentOnCharacter(victim, ObjTemplate.WearLocation.hand_one)) && wield.ItemType == ObjTemplate.ObjectType.weapon && !victim.HasInnate(Race.RACE_WEAPON_WIELD)) { SocketConnection.Act("You drop $p&n.", victim, wield, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n drops $p&n.", victim, wield, null, SocketConnection.MessageTarget.room); wield.RemoveFromChar(); wield.AddToRoom(victim.InRoom); } if ((wield2 = Object.GetEquipmentOnCharacter(victim, ObjTemplate.WearLocation.hand_two)) && wield2.ItemType == ObjTemplate.ObjectType.weapon && !victim.HasInnate(Race.RACE_WEAPON_WIELD)) { SocketConnection.Act("You drop $p&n.", victim, wield2, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n drops $p&n.", victim, wield2, null, SocketConnection.MessageTarget.room); wield2.RemoveFromChar(); wield2.AddToRoom(victim.InRoom); } ch.SendText("Ok.\r\n"); return; } if ("level".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (!victim.IsNPC()) { ch.SendText("Not on PC's.\r\n"); return; } if (value < 0 || value > Limits.MAX_ADVANCE_LEVEL) { ch.SendText("Level range is 0 to 40.\r\n"); return; } victim.Level = value; ch.SendText("Ok.\r\n"); return; } if ("wait".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 0 || value > 120) { ch.SendText("Wait range is 0 to 120.\r\n"); return; } victim.Wait = value; ch.SendText("Ok.\r\n"); return; } //if ( !MUDString.strcasecmp( arg2, "copper" ) ) //{ // victim.money.copper = value; // return; //} //if ( !MUDString.strcasecmp( arg2, "silver" ) ) //{ // victim.money.silver = value; // return; //} //if ( !MUDString.strcasecmp( arg2, "gold" ) ) //{ // victim.money.gold = value; // return; //} //if ( !MUDString.strcasecmp( arg2, "platinum" ) ) //{ // victim.money.platinum = value; // return; //} if ("hp".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase) || "hitpoints".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < -10 || value > 30000) { ch.SendText("HP range is -10 to 30,000 hit points.\r\n"); return; } if (victim.Fighting && value < 0) { ch.SendText("You cannot set a fighting person's hp below 0.\r\n"); return; } // Set their perm hitpoints so that their current max hitpoints will be reflected if (!ch.IsNPC()) { victim.MaxHitpoints = ((value * 100) / victim.GetCurrCon()) + 1; } else { victim.MaxHitpoints = value; } ch.SendText("Ok.\r\n"); return; } if ("mana".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 0 || value > 30000) { ch.SendText("Mana range is 0 to 30,000 mana points.\r\n"); return; } victim.MaxMana = value; ch.SendText("Ok.\r\n"); return; } if ("moves".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < 0 || value > 30000) { ch.SendText("Move range is 0 to 30,000 move points.\r\n"); return; } victim.MaxMoves = value; ch.SendText("Ok.\r\n"); return; } if ("alignment".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (value < -1000 || value > 1000) { ch.SendText("Alignment range is -1000 to 1000.\r\n"); return; } victim.Alignment = value; ch.SendText("Ok.\r\n"); return; } if ("thirsty".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if ((value < 0 || value > 100) && victim.GetTrust() < Limits.LEVEL_AVATAR) { ch.SendText("Thirst range is 0 to 100.\r\n"); return; } if (value < -1 || value > 100) { ch.SendText("Thirst range is -1 to 100.\r\n"); return; } ((PC)victim).Thirst = value; ch.SendText("Ok.\r\n"); return; } if ( "hunger".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase) || "hungry".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase) ) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if ((value < 0 || value > 100) && victim.GetTrust() < Limits.LEVEL_AVATAR) { ch.SendText("Hunger range is 0 to 100.\r\n"); return; } if (value < -1 || value > 100) { ch.SendText("Hunger range is -1 to 100.\r\n"); return; } ((PC)victim).Hunger = value; ch.SendText("Ok.\r\n"); return; } if ("experience".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < 0 || value > 100) { ch.SendText("Experience range is 0 to 100 (in percent).\r\n"); return; } victim.ExperiencePoints = (value * ExperienceTable.Table[victim.Level].LevelExperience) / 100; ch.SendText("Ok.\r\n"); return; } if ("frags".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < -1000 || value > 1000) { ch.SendText("Frag range is -1000 to 1000.\r\n"); return; } ((PC)victim).Frags = value; ch.SendText("Ok.\r\n"); return; } if ("drunkenness".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < 0 || value > 100) { ch.SendText("Drunk range is 0 to 100.\r\n"); return; } ((PC)victim).Drunk = value; ch.SendText("Ok.\r\n"); return; } if ("weight".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < 1 || value > 1000) { ch.SendText("Weight range is 1 to 1000 pounds.\r\n"); return; } ((PC)victim).Weight = value; ch.SendText("Ok.\r\n"); return; } if ("height".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < 1 || value > 120) { ch.SendText("Height range is 1 to 120 inches.\r\n"); return; } ((PC)victim).Height = value; ch.SendText("Ok.\r\n"); return; } if ("full".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if ((value < 0 || value > 100) && victim.GetTrust() < Limits.LEVEL_AVATAR) { ch.SendText("Full range is 0 to 100.\r\n"); return; } if (value < -1 || value > 100) { ch.SendText("Full range is -1 to 100.\r\n"); return; } ((PC)victim).Hunger = value; ch.SendText("Ok.\r\n"); return; } if ("name".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (!victim.IsNPC()) { ch.SendText("Not on PC's.\r\n"); return; } if (ch.StringTooLong(str[2])) return; victim.Name = str[2]; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "short")) { if (ch.StringTooLong(str[2])) return; victim.ShortDescription = str[2]; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "long")) { if (ch.StringTooLong(str[2])) return; victim.FullDescription = str[2] + "\r\n"; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "guild")) { Guild guild; Guild oldGuild; int count; bool found = false; if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if ((guild = Guild.GetGuild(str[2])) == null) { ch.SendText("That guild doesn't exist.\r\n"); return; } // remember the number of the available slot in the count // variable so we can fill that slot at the end of this code for (count = 0; count < Limits.MAX_GUILD_MEMBERS; ++count) { if (guild.Members[count].Filled == false) { found = true; break; } } if (!found) { ch.SendText("That guild is full.\r\n"); return; } if (((PC)victim).GuildMembership != null) { oldGuild = ((PC)victim).GuildMembership; oldGuild.NumMembers--; int count2; for (count2 = 0; count2 < Limits.MAX_GUILD_MEMBERS; count2++) { if (oldGuild.Members[count2].Name.Length == 0 || !MUDString.StringsNotEqual(oldGuild.Members[count2].Name, victim.Name)) { oldGuild.Members[count2].Filled = false; } } oldGuild.Save(); } ((PC)victim).GuildMembership = guild; ((PC)victim).GuildMembership.Name = guild.Name; ((PC)victim).GuildMembership.NumMembers++; if (((PC)victim).GuildRank == 0) ((PC)victim).GuildRank = Guild.Rank.normal; guild.Members[count].Name = victim.Name; guild.Members[count].Rank = ((PC)victim).GuildRank; guild.Members[count].Fine = 0; guild.Members[count].JoinTime = Database.SystemData.CurrentTime; guild.Members[count].Filled = true; ch.SendText("Guild initiation successful. Be sure to set rank.\r\n"); guild.Save(); ch.SendText("Ok.\r\n"); return; } if ("resistant".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { victim.Resistant = (Race.DamageType)value; ch.SendText("Ok.\r\n"); return; } if ("immune".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { victim.Immune = (Race.DamageType)value; ch.SendText("Ok.\r\n"); return; } if ("susceptible".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { victim.Susceptible = (Race.DamageType)value; ch.SendText("Ok.\r\n"); return; } if ("vulnerable".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { victim.Vulnerable = (Race.DamageType)value; ch.SendText("Ok.\r\n"); return; } if ("title".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase)) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } SetTitle(victim, str[2]); ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "spec")) { if (!victim.IsNPC()) { ch.SendText("Not on PC's.\r\n"); return; } List<MobSpecial> spec = MobSpecial.SpecMobLookup(str[2]); if (spec.Count < 1) { ch.SendText("No such spec fun.\r\n"); return; } victim.MobileTemplate.AddSpecFun(spec[0]); ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "death")) { if (!victim.IsNPC()) { ch.SendText("Not on PC's.\r\n"); return; } if ((victim.MobileTemplate.DeathFun = MobSpecial.SpecMobLookup(str[2])) == null) { ch.SendText("No such death fun.\r\n"); return; } ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "rank")) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } Guild.Rank rank; try { rank = (Guild.Rank)Enum.Parse(typeof(Guild.Rank), str[1], false); } catch (Exception) { ch.SendText("That's not a valid rank.\r\n"); return; } ((PC)victim).GuildRank = rank; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "points")) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } ((PC)victim).SkillPoints = value; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "tradition")) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (value < 0 || value >= TraditionData.Table.Length) { ch.SendText("Value out of range\r\n"); return; } ((PC)victim).Tradition = value; ch.SendText("Ok.\r\n"); return; } if (!MUDString.StringsNotEqual(str[1], "security")) { if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if ((value > ((PC)ch).Security && ch.GetTrust() < Limits.LEVEL_OVERLORD) || value < 0) { if (((PC)ch).Security > 0) { text += "Valid security is 0-" + ((PC)ch).Security + ".\r\n"; ch.SendText(text); } else { ch.SendText("Valid security is 0 only.\r\n"); } return; } ((PC)victim).Security = value; ch.SendText("Ok.\r\n"); return; } /* * Generate usage message. */ CommandType.Interpret(ch, "set mob"); return; }
/// <summary> /// Immortal command to force someone to do something. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Force(CharData ch, string[] str) { if( ch == null ) return; CharData realChar = ch.GetChar(); if (!realChar.Authorized("force")) return; if (str.Length < 2) { ch.SendText("Force whom to do what?\r\n"); return; } /* * Look for command in command table. */ int trust = ch.GetTrust(); foreach (CommandType cmd in CommandType.CommandTable) { if ( !MUDString.IsPrefixOf(str[0], cmd.Name) && (cmd.MinLevel > trust)) { ch.SendText("You can't even do that yourself!\r\n"); return; } } string action = String.Join(" ", str, 1, (str.Length - 1)); if (!MUDString.StringsNotEqual(str[0], "all")) { foreach (CharData worldChar in Database.CharList) { if (!worldChar.IsNPC() && worldChar.GetTrust() < ch.GetTrust()) { SocketConnection.Act("$n forces you to '$t'.", ch, action, worldChar, SocketConnection.MessageTarget.victim); CommandType.Interpret(worldChar, action); } } } else { CharData victim; if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } if (victim == ch) { ch.SendText("Aye aye, right away!\r\n"); return; } if (victim.GetTrust() >= ch.GetTrust()) { ch.SendText("Do it yourself!\r\n"); return; } SocketConnection.Act("$n forces you to '$t'.", ch, action, victim, SocketConnection.MessageTarget.victim); CommandType.Interpret(victim, action); } ch.SendText("Done.\r\n"); return; }
/// <summary> /// Set a skill to the specified value. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void SetSkill(CharData ch, string[] str) { if( ch == null ) return; if (str.Length < 3 || String.IsNullOrEmpty(str[0]) || String.IsNullOrEmpty(str[1]) || String.IsNullOrEmpty(str[2])) { ch.SendText("Syntax: set skill <victim> <skill> <value>\r\n"); ch.SendText("or: set skill <victim> all <value>\r\n"); ch.SendText("Skill being any skill.\r\n"); return; } CharData victim; if (!(victim = ch.GetCharWorld(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } if (ch.Level <= victim.Level && ch != victim) { ch.SendText("You may not set your peer nor your superior.\r\n"); return; } bool all = (str[1].Equals("all", StringComparison.CurrentCultureIgnoreCase)); Skill skl = null; if (!all && ((skl = Skill.SkillLookup(str[1])) == null)) { ch.SendText("No such skill.\r\n"); return; } if (!MUDString.IsNumber(str[2])) { ch.SendText("Value must be numeric.\r\n"); return; } int value = 0; Int32.TryParse(str[2], out value); if (value < 0 || value > Limits.MAX_SKILL_ADEPT) { ch.SendText("Value range is 0 to " + Limits.MAX_SKILL_ADEPT.ToString() + ".\r\n"); return; } if (all) { if (ch.GetTrust() < Limits.LEVEL_OVERLORD) { ch.SendText("Only immortals level " + Limits.LEVEL_OVERLORD.ToString() + " and up may set all skills.\r\n"); return; } foreach( SkillEntry entry in ch.CharacterClass.Skills ) { if( entry.Level < victim.GetTrust() ) { ((PC)victim).SkillAptitude[entry.Name] = value; } else { ((PC)victim).SkillAptitude[entry.Name] = 1; } } } else { ((PC)victim).SkillAptitude[skl.Name] = value; } ch.SendText("Ok.\r\n"); return; }
/// <summary> /// Checks the help files for the requested help entry and displays it if available. Checks for exact /// matches before trying to match the first keyword. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void HelpCommand(CharData ch, string[] str) { if( ch == null ) return; bool found = false; String query = String.Join(" ", str); if (ch == null) { Log.Error("Help: Called with null ch.", 0); return; } if (str.Length < 1 || str[0] == "commands") { Commands(ch, new [] { String.Empty } ); return; } // Try for exact matches first. foreach (Help help in Database.HelpList) { if (query.Equals(help.Keyword, StringComparison.CurrentCultureIgnoreCase)) { ch.SendText(help.ToString()); return; } } // Try for partial matches next. foreach (Help help in Database.HelpList) { if (help.MinimumLevel > ch.GetTrust()) { continue; } string[] keywords = help.Keyword.Split(' '); foreach( string key in keywords ) { if (key.StartsWith(str[0], StringComparison.CurrentCultureIgnoreCase)) { if (found) { ch.SendText("----------------------------------------------------------------------------\r\n"); } ch.SendText(help.ToString()); found = true; break; } } } if (!found) { string message = String.Format("Could not find help on '{0}'. You can ask us to create a help entry for that topic by typing 'requesthelp {0}'.\r\n", str[0]); ch.SendText(message + "\r\n"); } return; }
/// <summary> /// The main entry point for executing commands. /// Can be recursively called from 'at', 'order', 'force'. /// </summary> /// <param name="ch"></param> /// <param name="argument"></param> public static void Interpret(CharData ch, string argument) { // Get rid of leading and trailing spaces. argument = argument.Trim(); // Strip leading spaces. argument.Trim(); if (argument.Length == 0) { return; } // Remove AFK if (!ch.IsNPC()) { ch.RemoveActionBit(PC.PLAYER_AFK); } // Implement freeze command. if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_FREEZE)) { ch.SendText("You're totally frozen!\r\n"); return; } // Grab the command word. Special parsing so ' can be a command, // also no spaces needed after punctuation. string command; Object obj; Room room; int cmd; string logline = argument; int argptr = 0; if (!Char.IsLetter(argument[0]) && !Char.IsDigit(argument[0])) { command = argument.Substring(0, 1); argptr++; while (argument.Length > argptr && Char.IsWhiteSpace(argument[argptr])) { argument = argument.Remove(0, 1); } } else { command = MUDString.OneArgument(argument, ref argument); argument.Trim(); // Clean up the remainder of the command. } // Nothing to do if command is empty. Just send them a newline and bail. if (string.IsNullOrEmpty(command) && string.IsNullOrEmpty(argument)) { ch.SendText("\r\n"); return; } // Look for an item with a teleport trigger in the room. // and check to see if the command is a teleport trigger if (ch.InRoom && (obj = ch.GetObjHere(argument))) { if (obj.ItemType == ObjTemplate.ObjectType.teleport) { if (CheckCommandTrigger(command, obj.Values[1]) && obj.Values[2] != 0) { if (obj.Values[2] != -1) { obj.Values[2]--; } room = Room.GetRoom(obj.Values[0]); if (room) { SocketConnection.Act("$n&n vanishes suddenly.", ch, null, null, SocketConnection.MessageTarget.room); string text = String.Format("You {0} $p&n.\r\n", command); SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character); Log.Trace(String.Format("{0} activated keyword and was teleported by object.", ch.Name)); ch.RemoveFromRoom(); ch.AddToRoom(room); Interpret(ch, "look auto"); SocketConnection.Act("$n&n arrives suddenly.", ch, null, null, SocketConnection.MessageTarget.room); } else { ch.SendText("BUG: The target room for this teleporter does not exist.\r\n"); Log.Error("Target room for object {0} does not exist.", obj.ObjIndexData.IndexNumber); } return; } } else if (obj.ItemType == ObjTemplate.ObjectType.switch_trigger) { Exit exit; string cbuf = String.Format("Checking {0} against command no. {1} for {2}.", command, obj.Values[0], obj.Name); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, cbuf); if (CheckCommandTrigger(command, obj.Values[0])) { ch.SendText("Click.\r\n"); room = Room.GetRoom(obj.Values[1]); if (!room) { Log.Error("Target room for switch object {0} does not exist.", obj.ObjIndexData.IndexNumber); return; } exit = room.ExitData[obj.Values[2]]; if (exit == null) { Log.Error("Target exit for switch object {0} does not exist.", obj.ObjIndexData.IndexNumber); return; } if (exit.HasFlag(Exit.ExitFlag.blocked)) { exit.RemoveFlag(Exit.ExitFlag.blocked); } return; } } } // Look for command in command table. bool found = false; int trust = ch.GetTrust(); for (cmd = 0; cmd < CommandTable.Length; cmd++) { if (CommandTable[cmd].Name.StartsWith(command, StringComparison.CurrentCultureIgnoreCase) && (CommandTable[cmd].MinLevel <= trust)) { found = true; break; } } // Command was found, respond accordingly. if (found) { // Logging and snooping. if (CommandTable[cmd].LoggingType == LogType.never) { logline = "---- Nothing to see here ----"; } if ((!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_LOG)) || fLogAll || CommandTable[cmd].LoggingType == LogType.always) { string logBuf = String.Format("Log {0}: {1}", ch.Name, logline); Log.Trace(logBuf); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SECURE, ch.GetTrust(), logBuf); } if (ch.Socket && ch.Socket.SnoopBy) { ch.Socket.SnoopBy.WriteToBuffer("% "); ch.Socket.SnoopBy.WriteToBuffer(logline); ch.Socket.SnoopBy.WriteToBuffer("\r\n"); } // Break meditate if (CommandTable[cmd].BreakMeditate) { if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEDITATING)) { ch.RemoveActionBit(PC.PLAYER_MEDITATING); ch.SendText("You stop meditating.\r\n"); } } // Break sneak, hide, and invis // Anything that will break hide OR invis will break concealment // This is DUMB! Breaks invis w/backstab on a target that's not // there: i.e. "backstab trolll"/"backstab humann" . vis and no // attack! - (Should be handled with make_vis function). if (CommandTable[cmd].BreakInvisibility) { if (ch.IsAffected(Affect.AFFECT_INVISIBLE)) { ch.RemoveAffect(Affect.AFFECT_INVISIBLE); ch.RemoveAffect(Affect.AFFECT_HIDE); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); SocketConnection.Act("$n&n snaps into visibility.", ch, null, null, SocketConnection.MessageTarget.room); ch.SendText("You snap into visibility.\r\n"); } else if (ch.IsAffected(Affect.AFFECT_MINOR_INVIS)) { ch.RemoveAffect(Affect.AFFECT_INVISIBLE); ch.RemoveAffect(Affect.AFFECT_HIDE); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); ch.SendText("You appear.\r\n"); } } if (CommandTable[cmd].BreakHide) { if (ch.IsAffected(Affect.AFFECT_MINOR_INVIS)) { ch.SendText("You appear.\r\n"); } ch.AffectStrip( Affect.AffectType.skill, "shadow form"); ch.RemoveAffect( Affect.AFFECT_HIDE ); ch.RemoveAffect(Affect.AFFECT_MINOR_INVIS); } } // Command was not found, respond accordingly. else { // Look for command in socials table. if (!Database.SocialList.CheckSocial(ch, command, argument)) { if (!ch.IsNPC() && !MUDString.IsPrefixOf(command, "petition")) { string logBuf = String.Format("Log {0}: {1}", ch.Name, logline); Log.Trace(logBuf); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SECURE, ch.GetTrust(), logBuf); Command.Petition(ch, argument.Split(' ')); return; } Log.Trace("Failed to match command."); ch.SendText("Huh?\r\n"); } return; } // Character not in position for command? if (ch.CurrentPosition < CommandTable[cmd].MinPosition) { switch (ch.CurrentPosition) { case Position.dead: ch.SendText("Lie still; you are &+rDEAD&n!\r\n"); break; case Position.mortally_wounded: case Position.incapacitated: ch.SendText("You are hurt far too bad for that.\r\n"); break; case Position.stunned: ch.SendText("You are too stunned to do that.\r\n"); break; case Position.sleeping: ch.SendText("In your dreams, or what?\r\n"); break; case Position.reclining: ch.SendText("You can't do that while lying around.\r\n"); break; case Position.sitting: ch.SendText("You can't do this sitting!\r\n"); break; case Position.kneeling: ch.SendText("Get off your knees!\r\n"); break; case Position.resting: ch.SendText("Nah... You feel too relaxed...\r\n"); break; case Position.fighting: ch.SendText("No way! You are still fighting!\r\n"); break; } if (!ch.IsImmortal()) { return; } if (ch.CurrentPosition == Position.dead) ch.CurrentPosition = Position.sleeping; ch.SendText("You're not in the right position, but..\r\n"); } if (ch.IsAffected(Affect.AFFECT_MINOR_PARA) && CommandTable[cmd].Function != Command.LookCommand && CommandTable[cmd].Function != Command.Score && CommandTable[cmd].Function != Command.Attributes) { if (!ch.IsImmortal()) { ch.SendText("&+YYour mind moves, but your body doesn't.&n\r\n"); return; } ch.SendText("&+YYour immortality allows you to move!&n\r\n"); } string[] str = argument.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); // Dispatch the command. Catch any exceptions, since most exceptions will probably happen // based on user commands. try { (CommandTable[cmd].Function)(ch, str); } catch (Exception ex) { Log.Error("Exception in CommandType.Interpret: " + ex); } return; }