public static void do_flee(CharacterInstance ch, string argument) { if (ch.GetMyTarget() == null) { if (ch.IsInCombatPosition()) { ch.CurrentPosition = ch.CurrentMount != null ? PositionTypes.Mounted : PositionTypes.Standing; } ch.SendTo("You aren't fighting anyone."); return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Berserk), "Flee while berserking? You aren't thinking very clearly...")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.CurrentMovement <= 0, "You're too exhausted to flee from combat!")) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && (int)ch.CurrentPosition < (int)PositionTypes.Fighting, "You can't flee in an aggressive stance...")) { return; } if (ch.IsNpc() && (int)ch.CurrentPosition <= (int)PositionTypes.Sleeping) { return; } var wasIn = ch.CurrentRoom; comm.act(ATTypes.AT_FLEE, "You attempt to flee from combat, but can't escape!", ch, null, null, ToTypes.Character); if (AttemptToFlee(ch, wasIn)) { return; } if (!ch.IsNpc() && ch.Level < LevelConstants.AvatarLevel && SmaugRandom.Bits(3) == 1) { LoseExperience((PlayerInstance)ch); } }
public static void do_wimpy(CharacterInstance ch, string argument) { ch.SetColor(ATTypes.AT_YELLOW); var firstArg = argument.FirstWord(); int wimpy; if (firstArg.IsNullOrEmpty()) { wimpy = ch.MaximumHealth / 5; } else if (firstArg.EqualsIgnoreCase("max")) { if (ch.IsPKill()) { wimpy = (int)(ch.MaximumHealth / 2.25f); } else { wimpy = (int)(ch.MaximumHealth / 1.2f); } } else { wimpy = firstArg.ToInt32(); } if (CheckFunctions.CheckIfTrue(ch, wimpy < 0, "Your courage exceeds your wisdom.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsPKill() && wimpy > (int)(ch.MaximumHealth / 2.25f), "Such cowardice ill becomes you.")) { return; } if (CheckFunctions.CheckIfTrue(ch, wimpy > (int)(ch.MaximumHealth / 1.2f), "Such cowardice ill becomes you.")) { return; } ch.wimpy = wimpy; ch.Printf("Wimpy set to %d hit points.", wimpy); }
public static void Execute(string txt, CharacterInstance actor) { foreach (var mob in actor.CurrentRoom.Persons.OfType <MobileInstance>().Where(x => x.IsNpc())) { var mudProg = mob.MobIndex.MudProgs.FirstOrDefault(x => x.Type == MudProgTypes.Speech); if (mudProg == null) { continue; } if (actor.IsNpc() && ((MobileInstance)actor).MobIndex == mob.MobIndex) { continue; } CheckFunctions.CheckIfExecuteText(mob, mudProg, txt); } }
public static ReturnTypes spell_earthquake(int sn, int level, CharacterInstance ch, object vo) { var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); if (CheckFunctions.CheckIfTrueCasting(ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe), skill, ch)) { return(ReturnTypes.SpellFailed); } comm.act(ATTypes.AT_MAGIC, "The earth trembles beneath your feet!", ch, null, null, ToTypes.Character); comm.act(ATTypes.AT_MAGIC, "$n makes the earth tremble and shiver", ch, null, null, ToTypes.Room); var charDied = false; // TODO Don't display to everyone in the world, thats dumb return(charDied ? ReturnTypes.CharacterDied : ReturnTypes.None); }
public static void do_deities(CharacterInstance ch, string argument) { if (argument.IsNullOrEmpty()) { DisplayDeityList(ch); return; } var deity = RepositoryManager.Instance.GetEntity <DeityData>(argument); if (CheckFunctions.CheckIfNullObject(ch, deity, "&gThat deity does not exist.")) { return; } ch.PagerPrintfColor("&gDeity: &G%s", deity.Name); ch.PagerPrintfColor("&gDescription:\n\r&G%s", deity.Description); }
public static void do_bolt(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Bolt what?")) { return; } var exit = ch.FindExit(firstArg, true); if (exit == null) { ch.Printf("You see no %s here.", firstArg); return; } if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(firstArg)) { ch.Printf("You see no %s here.", firstArg); return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsDoor, "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's not closed.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsBolt, "You don't see a bolt.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Bolted, "It's already bolted.")) { return; } ch.SendTo("*Clunk*"); comm.act(ATTypes.AT_ACTION, "$n bolts the $d.", ch, null, exit.Keywords, ToTypes.Room); exit.SetFlagOnSelfAndReverseExit(ExitFlags.Bolted); }
public static void do_mpapply(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() || ((PlayerInstance)ch).Descriptor != null || ch.IsAffected(AffectedByTypes.Charm), "Huh?")) { return; } if (CheckFunctions.CheckIfEmptyString(ch, argument, "Mpapply - bad syntax")) { return; } var victim = ch.GetCharacterInRoom(argument); if (CheckFunctions.CheckIfNullObject(ch, victim, "Mpapply - no such player in room.")) { return; } if (CheckFunctions.CheckIfNullObject(ch, !victim.IsNpc() && ((PlayerInstance)victim).Descriptor != null, "Not on link-dead players")) { return; } if (!victim.IsNotAuthorized()) { return; } if (!victim.IsNpc() && ((PlayerInstance)victim).PlayerData.AuthState != AuthorizationStates.None) { return; } var buf = $"{victim.Name}@{(victim.IsNpc() ? string.Empty : ((PlayerInstance)victim).Descriptor.host)} new {victim.CurrentRace.GetName()} {victim.CurrentClass.GetName()} {(victim.IsPKill() ? "(Deadly)" : "(Peaceful)")} applying..."; ChatManager.to_channel(buf, ChannelTypes.Auth, "Auth", LevelConstants.ImmortalLevel); if (!victim.IsNpc()) { ((PlayerInstance)victim).PlayerData.AuthState = AuthorizationStates.None; } }
public static ReturnTypes spell_control_weather(int sn, int level, CharacterInstance ch, object vo) { if (CheckFunctions.CheckIfTrue(ch, !WeatherChangeTable.ContainsKey(Cast.TargetName.ToLower()), "What do you want to change about the weather?")) { return(ReturnTypes.SpellFailed); } var cell = WeatherManager.Instance.GetWeather(ch.CurrentRoom.Area); var change = 5.GetNumberThatIsBetween(SmaugRandom.Between(5, 15) + ch.Level / 10, 15); WeatherChangeTable[Cast.TargetName.ToLower()].Invoke(cell, change); var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); ch.SuccessfulCast(skill); return(ReturnTypes.None); }
private static void EmptyIntoObject(CharacterInstance ch, ObjectInstance obj, string arg) { var destObj = ch.GetObjectOnMeOrInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, destObj, "You can't find it.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, destObj, obj, "You can't empty something into itself!")) { return; } if (CheckFunctions.CheckIfTrue(ch, destObj.ItemType != ItemTypes.Container && destObj.ItemType != ItemTypes.KeyRing && destObj.ItemType != ItemTypes.Quiver, "That's not a container!")) { return; } if (((int)destObj.Values.Flags).IsSet(ContainerFlags.Closed)) { comm.act(ATTypes.AT_PLAIN, "The $d is closed.", ch, null, destObj.Name, ToTypes.Character); return; } destObj.Split(); if (obj.Empty(destObj)) { comm.act(ATTypes.AT_ACTION, "You empty $p into $P.", ch, obj, destObj, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n empties $p into $P.", ch, obj, destObj, ToTypes.Room); if (destObj.CarriedBy == null && GetSaveFlags().IsSet(AutoSaveFlags.Empty)) { save.save_char_obj(ch); } } else { comm.act(ATTypes.AT_ACTION, "$P is too full.", ch, obj, destObj, ToTypes.Character); } }
private static void RemoveDevotion(PlayerInstance ch) { if (CheckFunctions.CheckIfNullObject(ch, ch.PlayerData.CurrentDeity, "You have already chosen to worship no deities.")) { return; } var deity = ch.PlayerData.CurrentDeity; --deity.Worshippers; if (deity.Worshippers < 0) { deity.Worshippers = 0; } ch.PlayerData.Favor = -2500; ch.MentalState = -80; ch.SendTo("A terrible curse afflicts you as you forsake a deity!"); ch.AffectedBy.RemoveBits(deity.Affected); ch.Resistance.RemoveBit(deity.Element); ch.Susceptibility.RemoveBit(deity.Suscept); var af = new AffectData { Type = AffectedByTypes.Blind, Location = ApplyTypes.HitRoll, Modifier = -4, Duration = 50 * GameConstants.GetConstant <int>("AffectDurationConversionValue"), BitVector = ExtendedBitvector.Meb((int)AffectedByTypes.Blind) }; ch.AddAffect(af); // TODO Save the deity data to the database // save_deity(ch->pcdata->deity); ch.SendTo("You cease to worship any deity."); ch.PlayerData.CurrentDeity = null; save.save_char_obj(ch); }
private static void DropObject(CharacterInstance ch, string firstArg) { var obj = ch.GetCarriedObject(firstArg); if (CheckFunctions.CheckIfNullObject(ch, obj, "You do not have that item.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.CanDrop(obj), "You can't let go of it.")) { return; } obj.Split(); comm.act(ATTypes.AT_ACTION, "$n drops $p.", ch, obj, null, ToTypes.Room); comm.act(ATTypes.AT_ACTION, "You drop $p.", ch, obj, null, ToTypes.Character); obj.RemoveFrom(); obj = ch.CurrentRoom.AddTo(obj); MudProgHandler.ExecuteObjectProg(MudProgTypes.Drop, ch, obj); if (ch.CharDied() || handler.obj_extracted(obj)) { return; } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom)) { foreach (var clan in RepositoryManager.Instance.CLANS.Values) { if (clan.StoreRoom == ch.CurrentRoom.ID) { act_obj.save_clan_storeroom(ch, clan); } } } if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Drop)) { save.save_char_obj(ch); } }
private static void LockDoor(CharacterInstance ch, ExitData exit, string arg) { if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(arg)) { ch.Printf("You see no %s here.", arg); return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsDoor, "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's not closed.")) { return; } if (CheckFunctions.CheckIfTrue(ch, exit.Key <= 0, "It can't be locked.")) { return; } var key = ch.HasKey(exit.Key); if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Locked, "It's already locked.")) { return; } if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(arg)) { ch.SendTo("*Click*"); var count = key.Count; key.Count++; comm.act(ATTypes.AT_ACTION, "$n locks the $d with $p.", ch, key, exit.Keywords, ToTypes.Room); key.Count = count; exit.SetFlagOnSelfAndReverseExit(ExitFlags.Locked); } }
private static void UnlockObject(CharacterInstance ch, ObjectInstance obj) { if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Container, "That's not a container.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, obj.Value.ToList()[1], ContainerFlags.Closed, "It's not closed.")) { return; } if (CheckFunctions.CheckIfTrue(ch, obj.Value.ToList()[2] < 0, "It can't be unlocked.")) { return; } var key = ch.HasKey(obj.Value.ToList()[2]); if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, obj.Value.ToList()[1], ExitFlags.Locked, "It's already unlocked.")) { return; } obj.Value.ToList()[1].RemoveBit(ContainerFlags.Locked); ch.SendTo("*Click*"); var count = key.Count; key.Count = 1; comm.act(ATTypes.AT_ACTION, "$n unlocks $p with $P.", ch, obj, key, ToTypes.Room); key.Count = count; if (obj.Value.ToList()[1].IsSet(ContainerFlags.EatKey)) { key.Split(); key.Extract(); } }
public static void do_wake(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (string.IsNullOrEmpty(firstArg)) { interp.interpret(ch, "stand"); interp.interpret(ch, "look auto"); return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsAwake(), "You are asleep yourself!")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (victim.IsAwake()) { comm.act(ATTypes.AT_PLAIN, "$N is already awake.", ch, null, victim, ToTypes.Character); return; } if (victim.IsAffected(AffectedByTypes.Sleep) || (int)victim.CurrentPosition < (int)PositionTypes.Sleeping) { comm.act(ATTypes.AT_PLAIN, "You can't seem to wake $M!", ch, null, victim, ToTypes.Character); return; } comm.act(ATTypes.AT_ACTION, "You wake $M.", ch, null, victim, ToTypes.Character); victim.CurrentPosition = PositionTypes.Standing; comm.act(ATTypes.AT_ACTION, "$n wakes you.", ch, null, victim, ToTypes.Victim); interp.interpret(victim, "look auto"); }
public static void do_rip(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Rip ON or OFF?")) { return; } if (firstArg.EqualsIgnoreCase("on")) { EnableRip((PlayerInstance)ch); } else if (firstArg.EqualsIgnoreCase("off")) { DisableRip((PlayerInstance)ch); } else { ch.SendTo("Huh?!?"); } }
private static void SupplicateForAvatar(PlayerInstance ch, string argument) { var oldfavor = ch.PlayerData.Favor; if (CheckFunctions.CheckIfTrue(ch, ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SupplicateAvatarCost, "You are not favored enough for that.")) { return; } var template = RepositoryManager.Instance.MOBILETEMPLATES.Get(VnumConstants.MOB_VNUM_DEITY); var mob = RepositoryManager.Instance.CHARACTERS.Create(template); ch.CurrentRoom.AddTo(mob); comm.act(ATTypes.AT_MAGIC, "$n summons a powerful avatar!", ch, null, null, ToTypes.Room); comm.act(ATTypes.AT_MAGIC, "You summon a powerful avatar!", ch, null, null, ToTypes.Character); mob.AddFollower(ch); mob.AffectedBy.SetBit((int)AffectedByTypes.Charm); mob.Level = 10; mob.MaximumHealth = ch.MaximumHealth * 6 + ch.PlayerData.Favor; mob.CurrentAlignment = ch.PlayerData.CurrentDeity.Alignment; ch.PlayerData.Favor -= ch.PlayerData.CurrentDeity.SupplicateAvatarCost; if (ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SusceptNum) { ch.Susceptibility.SetBit(ch.PlayerData.CurrentDeity.Suscept); } if ((oldfavor > ch.PlayerData.CurrentDeity.AffectedNum && ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.AffectedNum) || (oldfavor > ch.PlayerData.CurrentDeity.ElementNum && ch.PlayerData.Favor <= ch.PlayerData.CurrentDeity.ElementNum) || (oldfavor < ch.PlayerData.CurrentDeity.SusceptNum && ch.PlayerData.Favor >= ch.PlayerData.CurrentDeity.SusceptNum)) { ch.update_aris(); } }
public static void do_afk(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfNpc(ch, ch)) { return; } if (ch.Act.IsSet((int)PlayerFlags.AwayFromKeyboard)) { ch.Act.RemoveBit((int)PlayerFlags.AwayFromKeyboard); } else { ch.Act.SetBit((int)PlayerFlags.AwayFromKeyboard); } var isAfkSet = ch.Act.IsSet((int)PlayerFlags.AwayFromKeyboard); ch.SendTo(isAfkSet ? "You are no longer afk." : "You are now afk."); comm.act(ATTypes.AT_GREY, isAfkSet ? "$n is no longer afk." : "$n is now afk.", ch, null, null, ToTypes.CanSee); }
private static ReturnTypes CastSingleTargetSpell(SkillData skill, int level, CharacterInstance ch, CharacterInstance victim) { if (CheckFunctions.CheckIfNullObjectCasting(victim, skill, ch)) { return(ReturnTypes.SpellFailed); } if (CheckFunctions.CheckIfTrueCasting( (skill.Type != SkillTypes.Herb && victim.Immunity.IsSet(ResistanceTypes.Magic)) || victim.IsImmune( EnumerationExtensions.GetEnum <ResistanceTypes>(Macros.SPELL_DAMAGE(skill))), skill, ch, CastingFunctionType.Immune, victim)) { return(ReturnTypes.SpellFailed); } if (CheckFunctions.CheckIfTrueCasting( victim.IsAffectedBy((int)skill.ID) && !skill.Flags.IsSet(SkillFlags.Accumulative) && !skill.Flags.IsSet(SkillFlags.ReCastable), skill, ch, CastingFunctionType.Failed, victim)) { return(ReturnTypes.SpellFailed); } var saf = skill.Affects.FirstOrDefault(); if (CheckFunctions.CheckIfTrueCasting(saf != null && saf.Location == (int)ApplyTypes.StripSN && !victim.IsAffectedBy(magic.ParseDiceExpression(ch, saf.Modifier)), skill, ch, CastingFunctionType.Failed, victim)) { return(ReturnTypes.SpellFailed); } return(CheckFunctions.CheckIfTrueCasting(skill.CheckSave(level, ch, victim), skill, ch, CastingFunctionType.Failed, victim) ? ReturnTypes.SpellFailed : ReturnTypes.None); }
public static void do_slay(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Slay whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Suicide is a mortal sin.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && victim.Trust >= ch.Trust, "You failed.")) { return; } var secondArg = argument.SecondWord(); if (SlayTable.ContainsKey(secondArg.ToLower())) { SlayTable[secondArg.ToLower()].Invoke(ch, victim); } else { Default(ch, victim); } handler.set_cur_char(victim); ch.RawKill(victim); }
private static void DropAllOrSome(CharacterInstance ch, string firstArg) { var all = firstArg.EqualsIgnoreCase("all"); var arg = all ? firstArg.Substring(4) : firstArg; if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDropAll) || ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom), "You can't seem to do that.")) { return; } var found = false; foreach (var obj in ch.Carrying) { if ((all || obj.Name.IsAnyEqual(arg)) && ch.CanSee(obj) && obj.WearLocation == WearLocations.None && ch.CanDrop(obj)) { // TODO } } }
public void CheckSearchResult() { bool successTitle = true; bool successAuthor = true; IWebElement firstProductTitle = null; IWebElement firstProductAuthor = null; SolutionBrowser._browser.Sync(); result.FirstProductClick(); firstProductTitle = pp.Title; firstProductAuthor = pp.AuthorLink; successTitle = CheckFunctions.CompareSearchResult(SEARCH_WORD, firstProductTitle); successAuthor = CheckFunctions.CompareSearchResult(SEARCH_WORD, firstProductAuthor); if (!successAuthor && !successTitle) { Assert.Fail("The first product was unrelated to the search."); } }
public static ReturnTypes spell_dispel_evil(int sn, int level, CharacterInstance ch, object vo) { var victim = (CharacterInstance)vo; var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); if (!ch.IsNpc() && ch.IsEvil()) { victim = ch; } if (victim.IsGood()) { comm.act(ATTypes.AT_MAGIC, "Thoric protects $N.", ch, null, victim, ToTypes.Room); return(ReturnTypes.SpellFailed); } if (victim.IsNeutral()) { comm.act(ATTypes.AT_MAGIC, "$N does not seem to be affected.", ch, null, victim, ToTypes.Character); return(ReturnTypes.SpellFailed); } if (CheckFunctions.CheckIfTrueCasting(victim.IsImmune(ResistanceTypes.Magic), skill, ch, CastingFunctionType.Immune, victim)) { return(ReturnTypes.SpellFailed); } var damage = SmaugRandom.Roll(level, 4); if (victim.SavingThrows.CheckSaveVsSpellStaff(level, victim)) { damage /= 2; } return(ch.CauseDamageTo(victim, damage, sn)); }
private static void DropCoins(CharacterInstance ch, int number) { if (CheckFunctions.CheckIfTrue(ch, ch.CurrentCoin < number, "You haven't got that many coins.")) { return; } ch.CurrentCoin -= number; var num = number; var obj = ch.CurrentRoom.Contents.FirstOrDefault(x => x.ID == VnumConstants.OBJ_VNUM_MONEY_ONE); if (obj != null) { num += 1; obj.Extract(); } else { obj = ch.CurrentRoom.Contents.FirstOrDefault(x => x.ID == VnumConstants.OBJ_VNUM_MONEY_SOME); if (obj != null) { num += obj.Value.ToList()[0]; obj.Extract(); } } comm.act(ATTypes.AT_ACTION, "$n drops some coin.", ch, null, null, ToTypes.Room); ch.CurrentRoom.AddTo(ObjectFactory.CreateMoney(num)); ch.SendTo("You let the coin slip from your hand."); if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Drop)) { save.save_char_obj(ch); } }
public static void do_pull(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Pull what?")) { return; } if (handler.FindObject_CheckMentalState(ch)) { return; } var obj = ch.GetObjectOnMeOrInRoom(firstArg); if (obj == null) { comm.act(ATTypes.AT_PLAIN, "I see no $T here.", ch, null, null, ToTypes.Character); return; } PullOrPush.pullorpush(ch, obj, true); }
public static void do_typo(CharacterInstance ch, string argument) { ch.SetColor(ATTypes.AT_PLAIN); if (CheckFunctions.CheckIfEmptyString(ch, argument, "Usage: 'typo <message>' (your location is automatically recorded)")) { if (ch.Trust >= LevelConstants.GetLevel(ImmortalTypes.Ascendant)) { ch.SendTo("Usage: 'typo list' or 'typo clear now'"); } return; } if (!argument.EqualsIgnoreCase("clear now") || ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Ascendant)) { return; } var path = SystemConstants.GetSystemFile(SystemFileTypes.Typo); using (var proxy = new TextWriterProxy(new StreamWriter(path, false))) proxy.Write(string.Empty); ch.SendTo("Typo file cleared."); }
private static void CloseDoor(CharacterInstance ch, ExitData exit, string firstArg) { if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(firstArg)) { ch.Printf("You see no %s here.", firstArg); return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsDoor, "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's already closed.")) { return; } comm.act(ATTypes.AT_ACTION, "$n closes the $d.", ch, null, exit.Keywords, ToTypes.Room); comm.act(ATTypes.AT_ACTION, "You close the $d.", ch, null, exit.Keywords, ToTypes.Character); var reverseExit = exit.GetReverse(); if (reverseExit != null) { reverseExit.Flags.SetBit(ExitFlags.Closed); foreach (var vch in exit.GetDestination(RepositoryManager.Instance).Persons) { comm.act(ATTypes.AT_ACTION, "The $d closes.", vch, null, reverseExit.Keywords, ToTypes.Character); } } exit.SetFlagOnSelfAndReverseExit(ExitFlags.Closed); // TODO Check room for traps }
public static void do_supplicate(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || ((PlayerInstance)ch).PlayerData.CurrentDeity == null, "You have no deity to supplicate to.")) { return; } var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Supplicate for what?")) { return; } if (SupplicateTable.ContainsKey(firstArg.ToLower())) { SupplicateTable[firstArg.ToLower()].Invoke((PlayerInstance)ch, argument); } else { ch.SendTo("You cannot supplicate for that."); } }
public static void do_drop(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Drop what?")) { return; } if (handler.FindObject_CheckMentalState(ch)) { return; } if (!ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Litterbug)) { ch.SetColor(ATTypes.AT_YELLOW); ch.SendTo("A godly force prevents you from dropping anything..."); return; } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDrop) && ch != db.Supermob) { ch.SetColor(ATTypes.AT_MAGIC); ch.SendTo("A magical force stops you!"); ch.SetColor(ATTypes.AT_TELL); ch.SendTo("Someone tells you, 'No littering here!'"); return; } var number = 0; var qty = firstArg.ParseWord(1, "."); if (!qty.IsNullOrEmpty() && qty.IsNumber()) { number = qty.ToInt32(); } if (CheckFunctions.CheckIfTrue(ch, number < 1, "That was easy...")) { return; } firstArg = firstArg.ParseWord(2, "."); if (number > 0 && (firstArg.EqualsIgnoreCase("coins") || firstArg.EqualsIgnoreCase("coin"))) { DropCoins(ch, number); } else if (number <= 1 && !firstArg.EqualsIgnoreCase("all") && !firstArg.StartsWithIgnoreCase("all.")) { DropObject(ch, firstArg); } else { DropAllOrSome(ch, firstArg); } if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Drop)) { save.save_char_obj(ch); } }
public static void do_say(CharacterInstance ch, string argument) { #if !SCRAMBLE var speaking = -1; /*foreach (int key in GameConstants.LanguageTable.Keys * .Where(key => (key & ch.Speaking) > 0)) * { * speaking = key; * break; * }*/ #endif if (CheckFunctions.CheckIfEmptyString(ch, argument, "Say what?")) { return; } if (CheckFunctions.CheckIf(ch, args => ((CharacterInstance)args[0]).CurrentRoom.Flags.IsSet((int)RoomFlags.Silence), "You can't do that here.", new List <object> { ch })) { return; } var actflags = ch.Act; if (ch.IsNpc()) { ch.Act.RemoveBit((int)ActFlags.Secretive); } foreach (var vch in ch.CurrentRoom.Persons.Where(vch => vch != ch)) { var sbuf = argument; if (vch.IsIgnoring(ch)) { if (!ch.IsImmortal() || vch.Trust > ch.Trust) { continue; } vch.SetColor(ATTypes.AT_IGNORE); vch.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name); } #if !SCRAMBLE /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking != 0)) * { * int speakswell = vch.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, vch)); * if (speakswell < 75) * sbuf = act_comm.TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]); * }*/ #else if (KnowsLanguage(vch, ch.Speaking, ch) == 0 && (!ch.IsNpc() || ch.Speaking != 0)) { sbuf = ScrambleText(argument, ch.Speaking); } #endif sbuf = sbuf.Drunkify(ch); // TODO Toggle global mobtrigger flag comm.act(ATTypes.AT_SAY, "$n says '$t'", ch, sbuf, vch, ToTypes.Victim); } ch.Act = actflags; // TODO Toggle global mobtrigger flag comm.act(ATTypes.AT_SAY, "You say '%T'", ch, null, argument.Drunkify(ch), ToTypes.Character); if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech)) { db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log), $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument}"); } MudProgHandler.ExecuteMobileProg(MudProgTypes.Speech, argument, ch); if (ch.CharDied()) { return; } MudProgHandler.ExecuteObjectProg(MudProgTypes.Speech, argument, ch); if (ch.CharDied()) { return; } MudProgHandler.ExecuteRoomProg(MudProgTypes.Speech, argument, ch); }
public static void do_shove(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Deadly), "Only deadly characters can shove.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't shove a player right now.")) { return; } var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Shove whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You shove yourself around, to no avail.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() || !((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.Deadly), "You can only shove deadly characters.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.Level.GetAbsoluteDifference(victim.Level) > 5, "There is too great an experience difference for you to even bother.")) { return; } if (CheckFunctions.CheckIfNullObject(ch, victim.HasTimer(TimerTypes.PKilled), "You can't shove that player right now.")) { return; } if (victim.CurrentPosition != PositionTypes.Standing) { comm.act(ATTypes.AT_PLAIN, "$N isn't standing up.", ch, null, victim, ToTypes.Character); return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Shove them in which direction?")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag), "That character cannot be shoved right now.")) { return; } victim.CurrentPosition = PositionTypes.Shove; var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg); var exit = ch.CurrentRoom.GetExit(exitDir); if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Closed) && (!victim.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor)), "There's no exit in that direction.")) { victim.CurrentPosition = PositionTypes.Standing; return; } var toRoom = exit.GetDestination(); if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death, "You cannot shove someone into a death trap.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim), "That character cannot enter that area.")) { victim.CurrentPosition = PositionTypes.Standing; return; } var chance = GetChanceByCharacterClass(ch); chance += (ch.GetCurrentStrength() - 15) * 3; chance += ch.Level - victim.Level; chance += GetBonusByCharacterRace(ch); if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed.")) { victim.CurrentPosition = PositionTypes.Standing; return; } comm.act(ATTypes.AT_ACTION, "You shove $M.", ch, null, victim, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n shoves you.", ch, null, victim, ToTypes.Victim); Move.move_char(victim, exit, 0); if (!victim.CharDied()) { victim.CurrentPosition = PositionTypes.Standing; } Macros.WAIT_STATE(ch, 12); if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag)) { ch.AddTimer(TimerTypes.ShoveDrag, 10); } }