public static void do_title(CharacterInstance ch, string argument) { if (ch.IsNpc()) { return; } ch.SetColor(ATTypes.AT_SCORE); if (CheckFunctions.CheckIfTrue(ch, ch.Level < 5, "Sorry... you must be at least level 5 to set your title...")) { return; } if (CheckFunctions.CheckIfSet(ch, ((PlayerInstance)ch).PlayerData.Flags, PCFlags.NoTitle, "The gods prohibit you from changing your title.")) { return; } if (CheckFunctions.CheckIfEmptyString(ch, argument, "Change your title to what?")) { return; } var buffer = argument.Length > 50 ? argument.Substring(0, 50) : argument; buffer.SmashTilde(); player.set_title((PlayerInstance)ch, buffer); ch.SendTo("Ok."); }
private static void LockObject(CharacterInstance ch, ObjectInstance obj, string arg) { if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Container, "That's not a container.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, obj.Values.Flags, ContainerFlags.Closed, "It's not closed.")) { return; } if (CheckFunctions.CheckIfTrue(ch, obj.Values.KeyID <= 0, "It can't be locked.")) { return; } var key = ch.HasKey((int)obj.Values.KeyID); if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key.")) { return; } if (CheckFunctions.CheckIfSet(ch, obj.Values.Flags, ContainerFlags.Locked, "It's already locked.")) { return; } obj.Values.Flags = obj.Values.Flags.SetBit(ContainerFlags.Locked); ch.SendTo("*Click*"); var count = key.Count; key.Count = 1; comm.act(ATTypes.AT_ACTION, "$n locks $p with $P.", ch, obj, key, ToTypes.Room); key.Count = count; }
public void CheckIfSet() { var actor = new CharacterInstance(1, "TestNpc"); const int bitField = 2 | 4 | 8; Assert.That(CheckFunctions.CheckIfSet(actor, bitField, 4), Is.True); }
private static void OpenDoor(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.CheckIfTrue(ch, !exit.Flags.IsSet(ExitFlags.IsDoor) || exit.Flags.IsSet(ExitFlags.Dig), "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's already open.")) { return; } if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Locked) && exit.Flags.IsSet(ExitFlags.Bolted), "The bolt is locked.")) { return; } if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Bolted, "It's bolted.")) { return; } if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Locked, "It's locked.")) { return; } if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(arg)) { comm.act(ATTypes.AT_ACTION, "$n opens the $d.", ch, null, exit.Keywords, ToTypes.Room); comm.act(ATTypes.AT_ACTION, "You open the $d.", ch, null, exit.Keywords, ToTypes.Character); var reverseExit = exit.GetReverse(); if (reverseExit != null) { var room = exit.GetDestination(RepositoryManager.Instance); foreach (var vch in room.Persons) { comm.act(ATTypes.AT_ACTION, "The $d opens.", vch, null, reverseExit.Keywords, ToTypes.Character); } } exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Closed); // TODO Check for traps } }
private static void SupplicateForCorpse(PlayerInstance ch, string argument) { var oldfavor = ch.PlayerData.Favor; if (CheckFunctions.CheckIfTrue(ch, ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SupplicateCorpseCost, "You are not favored enough for a corpse retrieval.")) { return; } if (CheckFunctions.CheckIfSet(ch, ch.CurrentRoom.Flags, RoomFlags.ClanStoreroom, "You cannot supplicate in a storage room.")) { return; } var corpse = ch.CurrentRoom.Contents.FirstOrDefault( x => x.ShortDescription.Equals($"the corpse of {ch.Name}")); if (CheckFunctions.CheckIfNullObject(ch, corpse, "No corpse of yours litters the world...")) { return; } if (CheckFunctions.CheckIfSet(ch, corpse.InRoom.Flags, RoomFlags.NoSupplicate, "The image of your corpse appears, but suddenly fades away.")) { return; } comm.act(ATTypes.AT_MAGIC, "Your corpse appears suddenly, surrounded by a divine presence...", ch, null, null, ToTypes.Character); comm.act(ATTypes.AT_MAGIC, "$n's corpse appears suddenly, surrounded by a divine force...", ch, null, null, ToTypes.Room); corpse.InRoom.RemoveFrom(corpse); ch.CurrentRoom.AddTo(corpse); corpse.ExtraFlags.RemoveBit((int)ItemExtraFlags.Buried); ch.PlayerData.Favor -= ch.PlayerData.CurrentDeity.SupplicateCorpseCost; 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(); } }
private static void BashSomething(CharacterInstance actor, ExitData exit, SkillData skill, string arg) { if (CheckFunctions.CheckIfSet(actor, exit.Flags, ExitFlags.Closed, "Calm down. It is already open.")) { return; } Macros.WAIT_STATE(actor, skill.Rounds); var keyword = exit.Flags.IsSet(ExitFlags.Secret) ? "wall" : exit.Keywords; var chance = !actor.IsNpc() ? Macros.LEARNED(actor, (int)skill.ID) / 2 : 90; if (exit.Flags.IsSet(ExitFlags.Locked)) { chance /= 3; } if (exit.Flags.IsSet(ExitFlags.BashProof) || actor.CurrentMovement < 15 || SmaugRandom.D100() >= chance + 4 * (actor.GetCurrentStrength() - 19)) { Bash(actor, skill, arg); return; } BashExit(exit); comm.act(ATTypes.AT_SKILL, "Crash! You bashed open the $d!", actor, null, keyword, ToTypes.Character); comm.act(ATTypes.AT_SKILL, "$n bashes open the $d!", actor, null, keyword, ToTypes.Room); skill.LearnFromSuccess(actor); var reverseExit = exit.GetReverse(); BashExit(reverseExit); var destination = exit.GetDestination(RepositoryManager.Instance); foreach (var ch in destination.Persons) { comm.act(ATTypes.AT_SKILL, "The $d crashes open!", ch, null, reverseExit.Keywords, ToTypes.Character); } actor.CauseDamageTo(actor, actor.CurrentHealth / 20, (int)skill.ID); }
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); } }
private static void SupplicateForRecall(PlayerInstance ch, string argument) { var oldfavor = ch.PlayerData.Favor; if (CheckFunctions.CheckIfTrue(ch, ch.PlayerData.Favor < ch.PlayerData.CurrentDeity.SupplicateRecallCost, "Your favor is inadequate for such a supplication.")) { return; } if (CheckFunctions.CheckIfSet(ch, ch.CurrentRoom.Flags, RoomFlags.NoSupplicate, "You have been forsaken!")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.RecentFight) && !ch.IsImmortal(), "You cannot supplicate recall under adrenaline!")) { return; } RoomTemplate location = null; if (!ch.IsNpc() && ch.PlayerData.Clan != null) { location = RepositoryManager.Instance.ROOMS.Get(ch.PlayerData.Clan.RecallRoom); } if (!ch.IsNpc() && location == null && ch.Level >= 5 && ch.PlayerData.Flags.IsSet(PCFlags.Deadly)) { location = RepositoryManager.Instance.ROOMS.Get(VnumConstants.ROOM_VNUM_DEADLY); } if (location == null) { var raceRecallRoom = RepositoryManager.Instance.RACES.Get(ch.CurrentRace.GetValue()).RaceRecallRoom; location = RepositoryManager.Instance.ROOMS.Get(raceRecallRoom); } if (location == null) { location = RepositoryManager.Instance.ROOMS.Get(VnumConstants.ROOM_VNUM_TEMPLE); } if (CheckFunctions.CheckIfNullObject(ch, location, "You are completely lost.")) { return; } comm.act(ATTypes.AT_MAGIC, "$n disappears in a column of divine power.", ch, null, null, ToTypes.Room); var oldRoom = ch.CurrentRoom; oldRoom.RemoveFrom(ch); location.AddTo(ch); if (ch.CurrentMount != null) { oldRoom.RemoveFrom(ch.CurrentMount); location.AddTo(ch.CurrentMount); } comm.act(ATTypes.AT_MAGIC, "$n appears in the room from a column of divine power.", ch, null, null, ToTypes.Room); Look.do_look(ch, "auto"); ch.PlayerData.Favor -= ch.PlayerData.CurrentDeity.SupplicateRecallCost; 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(); } }
private static object TargetCharacterWithOffensiveSpell(string arg, CharacterInstance ch, bool silence, SkillData skill) { CharacterInstance victim; if (arg.IsNullOrEmpty()) { victim = ch.GetMyTarget(); if (CheckFunctions.CheckIfNullObject(ch, victim, !silence ? "Cast the spell on whom?" : "")) { return(null); } } else { victim = ch.GetCharacterInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, !silence ? "They aren't here." : "")) { return(null); } } // Nuisance flag will pick who you are fighting for offensive spells up to 92% of the time if (!ch.IsNpc() && ch.CurrentFighting != null && ((PlayerInstance)ch).PlayerData.Nuisance != null && ((PlayerInstance)ch).PlayerData.Nuisance.Flags > 5 && SmaugRandom.D100() < (((PlayerInstance)ch).PlayerData.Nuisance.Flags - 5) * 8 + 6 * ((PlayerInstance)ch).PlayerData.Nuisance.Power) { victim = ch.GetMyTarget(); } if (fight.is_safe(ch, victim, true)) { return(null); } if (ch == victim) { if (CheckFunctions.CheckIfSet(ch, skill.Flags, SkillFlags.NoSelf, !silence ? "You can't cast this on yourself!" : "")) { return(null); } if (!silence) { ch.SendTo("Cast this on yourself? Okay..."); } } if (!ch.IsNpc()) { if (!victim.IsNpc()) { if (CheckFunctions.CheckIfTrue(ch, ch.GetTimer(TimerTypes.PKilled) != null, !silence ? "You have been killed in the last 5 minutes." : "")) { return(null); } if (CheckFunctions.CheckIfTrue(ch, victim.GetTimer(TimerTypes.PKilled) != null, !silence ? "This player has been killed in the last 5 minutes." : "")) { return(null); } if (CheckFunctions.CheckIfTrue(ch, ch.Act.IsSet((int)PlayerFlags.Nice) && ch != victim, !silence ? "You are too nice to attack another player." : "")) { return(null); } if (victim != ch) { if (!silence) { ch.SendTo("You really shouldn't do this to another player..."); } else if (victim.GetMyTarget() != ch) { return(null); } } } if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim, !silence ? "You can't do that to your own follower." : "")) { return(null); } } fight.check_illegal_pk(ch, victim); return(victim); }
private static void PlaceItemForAuction(CharacterInstance ch, string argument, IAuctionManager auctionManager) { var firstArg = argument.FirstWord(); var obj = ch.GetCarriedObject(firstArg); if (CheckFunctions.CheckIfNullObject(ch, obj, "You aren't carrying that.")) { return; } if (CheckFunctions.CheckIfTrue(ch, obj.Timer > 0, "You can't auction objects that are decaying.")) { return; } if (CheckFunctions.CheckIfSet(ch, obj.ExtraFlags, (int)ItemExtraFlags.Personal, "Personal items may not be auctioned.")) { return; } if (CheckFunctions.CheckIfTrue(ch, (auctionManager ?? AuctionManager.Instance).Repository.History.Any(x => x.ItemForSale == obj.ObjectIndex.ID), "Such an item has been auctioned recently, try again later.")) { return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Auction it for what?")) { return; } if (CheckFunctions.CheckIfTrue(ch, !secondArg.IsNumber(), "You must input a number at which to start the auction.")) { return; } var startingBid = secondArg.ToInt32(); if (CheckFunctions.CheckIfTrue(ch, startingBid <= 0, "You can't auction something for nothing!")) { return; } if ((auctionManager ?? AuctionManager.Instance).Auction != null) { comm.act(ATTypes.AT_TELL, "Try again later - $p is being auctioned right now!", ch, (auctionManager ?? AuctionManager.Instance).Auction.ItemForSale, null, ToTypes.Character); if (!ch.IsImmortal()) { Macros.WAIT_STATE(ch, GameConstants.GetSystemValue <int>("PulseViolence")); } return; } if (!obj.HasAttribute <AuctionableAttribute>()) { comm.act(ATTypes.AT_TELL, "You cannot auction $Ts.", ch, null, obj.GetItemTypeName(), ToTypes.Character); return; } obj.Split(); obj.RemoveFrom(); if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Auction)) { save.save_char_obj(ch); } (auctionManager ?? AuctionManager.Instance).StartAuction(ch, obj, startingBid); ChatManager.talk_auction($"A new item is being auctioned: {obj.ShortDescription} at {startingBid} coin."); }
public static void do_drag(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfNpc(ch, ch, "Only characters can drag.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't drag a player right now.")) { return; } var pch = (PlayerInstance)ch; var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(pch, firstArg, "Drag whom?")) { return; } var victim = pch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(pch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(pch, pch, victim, "You take yourself by the scruff of your neck, but go nowhere.")) { return; } if (CheckFunctions.CheckIfNpc(ch, victim, "You can only drag characters.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.Act.IsSet((int)PlayerFlags.ShoveDrag) || (!victim.IsNpc() && !victim.IsDeadly()), "That character doesn't seem to appreciate your attentions.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.HasTimer(TimerTypes.PKilled), "You can't drag that player right now.")) { return; } if (CheckFunctions.CheckIf(ch, HelperFunctions.IsFighting, "You try, but can't get close enough.", new List <object> { ch })) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !victim.IsDeadly() && ch.IsDeadly(), "You can't drag a deadly character.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !ch.IsDeadly() && (int)ch.CurrentPosition > 3, "They don't seem to need your assistance.")) { return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Drag them in which direction?")) { return; } if (CheckFunctions.CheckIfTrue(ch, Math.Abs(ch.Level - victim.Level) > 5, "There is too great an experience difference for you to even bother.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && victim.GetTimer(TimerTypes.ShoveDrag) == null, "That character cannot be dragged right now.")) { return; } var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg); var exit = ch.CurrentRoom.GetExit(exitDir); if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !IsPassable(exit, victim), "There's no exit in that direction.")) { return; } var toRoom = exit.GetDestination(); if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death, "You cannot drag someone into a death trap.")) { 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 = CalculateChanceToDrag(ch, victim); if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if ((int)victim.CurrentPosition < (int)PositionTypes.Standing) { DragIntoNextRoom(ch, victim, exit); return; } ch.SendTo("You cannot do that to someone who is standing."); }