public static void do_dismiss(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Dismiss whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (victim.IsAffected(AffectedByTypes.Charm) && victim.IsNpc() && victim.Master == ch) { victim.StopFollower(); ((MobileInstance)victim).StopHating(); ((MobileInstance)victim).StopHunting(); ((MobileInstance)victim).StopFearing(); comm.act(ATTypes.AT_ACTION, "$n dismisses $N.", ch, null, victim, ToTypes.NotVictim); comm.act(ATTypes.AT_ACTION, "You dismiss $N.", ch, null, victim, ToTypes.Character); return; } ch.SendTo("You cannot dismiss them."); }
public static void do_brandish(CharacterInstance ch, string argument) { var obj = ch.GetEquippedItem(WearLocations.Hold); if (CheckFunctions.CheckIfNullObject(ch, obj, "You hold nothing in your hand.")) { return; } if (CheckFunctions.CheckIfTrue(ch, obj.ItemType != ItemTypes.Staff, "You can brandish only with a staff.")) { return; } if (obj.Value.ToList()[3] <= 0) { throw new InvalidDataException($"Object {obj.ID} has no skill ID assigned to Value[3]"); } Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence")); if (obj.Value.ToList()[2] > 0) { BrandishStaff(ch, obj); } if (--obj.Value.ToList()[2] <= 0) { comm.act(ATTypes.AT_MAGIC, "$p blazes bright and vanishes from $n's hands!", ch, obj, null, ToTypes.Room); comm.act(ATTypes.AT_MAGIC, "$p blazes bright and is gone!", ch, obj, null, ToTypes.Character); obj.Extract(); } }
private static object TargetCharacterWithDefensiveSpell(string arg, CharacterInstance ch, bool silence, SkillData skill) { CharacterInstance victim; if (arg.IsNullOrEmpty()) { victim = ch; } 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 defensive spells up to 36% 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(); } return(CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), !silence ? "You can't cast this on yourself!" : "") ? null : victim); }
public static void do_track(CharacterInstance ch, string argument) { var skill = RepositoryManager.Instance.GetEntity <SkillData>("track"); if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && ((PlayerInstance)ch).PlayerData.GetSkillMastery(skill.ID) <= 0, "You do not know of this skill yet.")) { return; } var arg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, arg, "Whom are you trying to track?")) { return; } Macros.WAIT_STATE(ch, skill.Rounds); var victim = ch.GetCharacterInWorld(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, "You can't find a trail of anyone like that.")) { return; } }
public static void StopAuction(CharacterInstance ch, string argument, IAuctionManager auctionManager) { if (CheckFunctions.CheckIfNullObject(ch, (auctionManager ?? AuctionManager.Instance).Auction, "There is no auction to stop.")) { return; } ch.SetColor(ATTypes.AT_LBLUE); var auction = (auctionManager ?? AuctionManager.Instance).Auction; ChatManager.talk_auction(string.Format(argument, auction.ItemForSale.ShortDescription)); auction.ItemForSale.AddTo(auction.Seller); if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Auction)) { save.save_char_obj(auction.Seller); } if (auction.Buyer != null && auction.Buyer != auction.Seller) { auction.Buyer.CurrentCoin += auction.BidAmount; auction.Buyer.SendTo("Your money has been returned."); } (auctionManager ?? AuctionManager.Instance).StopAuction(); }
public static void do_bestowarea(CharacterInstance ch, string argument) { ch.SetColor(ATTypes.AT_IMMORT); if (string.IsNullOrEmpty(argument)) { ch.SendTo("Syntax:"); ch.SendTo("bestowarea <victim> <filename>.are"); ch.SendTo("bestowarea <victim> none (removes bestowed areas)"); ch.SendTo("bestowarea <victim> list (lists bestowed areas)"); ch.SendTo("bestowarea <victim> (lists bestowed areas)"); return; } var firstArg = argument.FirstWord(); var victim = ch.GetCharacterInWorld(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfNpc(ch, victim, "You can't give special abilities to a mob!")) { return; } if (!victim.IsImmortal()) { ch.SendTo("They aren't an immortal."); return; } var secondArg = argument.SecondWord(); if (string.IsNullOrEmpty(secondArg) || secondArg.EqualsIgnoreCase("list")) { var areaNames = ((PlayerInstance)victim).PlayerData.Bestowments.Where(x => x.EndsWith(".are")); ch.SendTo($"Bestowed Areas: {string.Join(", ", areaNames)}"); return; } if (secondArg.EqualsIgnoreCase("none")) { ((PlayerInstance)victim).PlayerData.Bestowments = ((PlayerInstance)victim).PlayerData.Bestowments.Where(x => !x.EndsWith(".are")).ToList(); ch.SendTo("Done."); return; } if (!secondArg.EndsWith(".are")) { ch.SendTo("You can only bestow an area name."); ch.SendTo("e.g. bestow joe sam.are"); return; } ((PlayerInstance)victim).PlayerData.Bestowments.Add(secondArg); victim.SetColor(ATTypes.AT_IMMORT); victim.SendTo($"{ch.Name} has bestowed on you the area: {secondArg}"); ch.SendTo("Done."); }
public static void do_consider(CharacterInstance ch, string argument) { var arg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, arg, "Consider killing whom?")) { return; } var victim = ch.GetCharacterInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They're not here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You decide you're pretty sure you could take yourself in a fight.")) { return; } var levelDiff = victim.Level - ch.Level; var msg = GetLevelConsiderMessage(levelDiff); comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character); levelDiff = (victim.MaximumHealth - ch.MaximumHealth) / 6; msg = GetHealthConsiderMessage(levelDiff); comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character); }
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; }
private static ObjectInstance GetDrinkSource(CharacterInstance ch, string arg) { var obj = string.IsNullOrEmpty(arg) ? ch.CurrentRoom.Contents.FirstOrDefault(x => x.ItemType == ItemTypes.Fountain) : ch.GetObjectOnMeOrInRoom(arg); return(CheckFunctions.CheckIfNullObject(ch, obj, string.IsNullOrEmpty(arg) ? "Drink what?" : "You can't find it.") ? obj : obj); }
public static void do_follow(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Follow whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (ch.IsAffected(AffectedByTypes.Charm) && ch.Master != null) { comm.act(ATTypes.AT_PLAIN, "But you'd rather follow $N!", ch, null, ch.Master, ToTypes.Character); return; } if (victim == ch) { if (CheckFunctions.CheckIfNullObject(ch, ch.Master, "You already follow yourself.")) { return; } ch.StopFollower(); return; } if ((ch.Level - victim.Level < -10 || ch.Level - victim.Level > 10) && !ch.IsHero() && !(ch.Level < 15 && !victim.IsNpc() && ((PlayerInstance)victim).PlayerData.Council != null && !((PlayerInstance)victim).PlayerData.Council.Name.Equals("Newbie Council"))) { ch.SendTo("You are not of the right caliber to follow."); return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsCircleFollowing(victim), "Following in loops is not allowed... sorry.")) { return; } if (ch.Master != null) { ch.StopFollower(); } ch.AddFollower(victim); }
public static void do_empty(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Empty what?")) { return; } if (handler.FindObject_CheckMentalState(ch)) { return; } var obj = ch.GetCarriedObject(firstArg); if (CheckFunctions.CheckIfNullObject(ch, obj, "You aren't carrying that.")) { return; } if (obj.Count > 1) { obj.Split(); } var secondArg = argument.SecondWord(); if (secondArg.EqualsIgnoreCase("into")) { secondArg = argument.ThirdWord(); } switch (obj.ItemType) { case ItemTypes.Pipe: EmptyPipe(ch, obj); break; case ItemTypes.DrinkContainer: EmptyDrinkContainer(ch, obj); break; case ItemTypes.Quiver: case ItemTypes.Container: EmptyContainerOrQuiver(ch, obj); break; case ItemTypes.KeyRing: EmptyKeyRing(ch, obj, secondArg); break; default: comm.act(ATTypes.AT_ACTION, "You shake $p in an attempt to empty it...", ch, obj, null, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n begins to shake $p in an attempt to empty it...", ch, obj, null, ToTypes.Room); break; } }
private static object TargetObjectInInventory(string arg, CharacterInstance ch, bool silence) { if (CheckFunctions.CheckIfEmptyString(ch, arg, !silence ? "What should the spell be cast upon?" : "")) { return(null); } var obj = ch.GetCarriedObject(arg); return(CheckFunctions.CheckIfNullObject(ch, obj, !silence ? "You are not carrying that." : "") ? null : obj); }
public static void do_mix(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "What would you like to mix together?")) { return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "What would you like to mix together?")) { return; } var firstObj = ch.GetCarriedObject(firstArg); if (CheckFunctions.CheckIfNullObject(ch, firstObj, "You aren't carrying that.")) { return; } var secondObj = ch.GetCarriedObject(secondArg); if (CheckFunctions.CheckIfNullObject(ch, secondObj, "You aren't carrying that.")) { return; } if (CheckFunctions.CheckIfTrue(ch, firstObj.ItemType != ItemTypes.DrinkContainer && firstObj.ItemType != ItemTypes.DrinkMixture && secondObj.ItemType != ItemTypes.DrinkContainer && secondObj.ItemType != ItemTypes.DrinkMixture, "You can't mix that!")) { return; } if (CheckFunctions.CheckIfTrue(ch, firstObj.Values.Quantity <= 0 || secondObj.Values.Quantity <= 0, "It's empty.")) { return; } var success = CheckMixture(firstObj, secondObj); if (CheckFunctions.CheckIfTrue(ch, !success, "Those two don't mix well together.")) { return; } ch.SendTo("&cYou mix them together.&g"); }
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(); } }
public static void do_kill(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfEmptyString(ch, argument, "Kill whom?")) { return; } var firstArg = argument.FirstWord(); var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() && victim.CurrentMorph != null, "This creature appears strange to you. Look upon it more closely before attempting to kill it.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && !victim.Act.IsSet((int)PlayerFlags.Killer) && !victim.Act.IsSet((int)PlayerFlags.Thief), "You must MURDER a player.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You hit yourself. Ouch!")) { fight.multi_hit(ch, ch, Program.TYPE_UNDEFINED); return; } if (fight.is_safe(ch, victim, true)) { return; } if (ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim) { comm.act(ATTypes.AT_PLAIN, "$N is your beloved master.", ch, null, victim, ToTypes.Character); return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!")) { return; } Macros.WAIT_STATE(ch, 1 * GameConstants.GetSystemValue <int>("PulseViolence")); ch.CheckAttackForAttackerFlag(victim); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); }
public static void do_glance(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfNullObject(ch, ((PlayerInstance)ch).Descriptor)) { return; } if (CheckFunctions.CheckIfTrue(ch, (int)ch.CurrentPosition < (int)PositionTypes.Sleeping, "You can't see anything but stars!")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.CurrentPosition == PositionTypes.Sleeping, "You can't see anything, you're sleeping!")) { return; } if (CheckFunctions.CheckIfBlind(ch, "You can't see a thing!")) { return; } ch.SetColor(ATTypes.AT_ACTION); var firstWord = argument.FirstWord(); if (string.IsNullOrEmpty(firstWord)) { GlanceAtRoom(ch); return; } var victim = ch.GetCharacterInRoom(firstWord); if (CheckFunctions.CheckIfNullObject(ch, victim, "They're not here.")) { return; } if (victim.CanSee(ch)) { comm.act(ATTypes.AT_ACTION, "$n glances at you.", ch, null, victim, ToTypes.Victim); comm.act(ATTypes.AT_ACTION, "$n glances at $N.", ch, null, victim, ToTypes.NotVictim); } if (ch.IsImmortal() && victim != ch) { GlanceFromImmortal(ch, victim); } }
private static void UnlockDoor(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 not closed.")) { return; } if (CheckFunctions.CheckIfTrue(ch, exit.Key < 0, "It can't be unlocked.")) { 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 unlocked.")) { return; } if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(firstArg)) { ch.SendTo("*Click*"); var count = key.Count; key.Count = 1; comm.act(ATTypes.AT_ACTION, "$n unlocks the $d with $p.", ch, key, exit.Keywords, ToTypes.Room); key.Count = count; if (exit.Flags.IsSet(ExitFlags.EatKey)) { key.Split(); key.Extract(); } exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Locked); } }
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_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; } }
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 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 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 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_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); }
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); } }
public static void do_at(CharacterInstance ch, string argument) { ch.SetColor(ATTypes.AT_IMMORT); var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "At where what?")) { return; } RoomTemplate location = null; CharacterInstance worldCharacter = null; if (argument.IsNumber()) { location = RepositoryManager.Instance.GetEntity <RoomTemplate>(argument); } else if (argument.EqualsIgnoreCase("pk")) { // todo get last pkroom } else { worldCharacter = RepositoryManager.Instance.GetEntity <CharacterInstance>(argument); if (CheckFunctions.CheckIf(ch, () => worldCharacter?.CurrentRoom == null, "No such mobile or player in the world.")) { return; } } if (location == null && worldCharacter != null) { location = worldCharacter.CurrentRoom; } if (CheckFunctions.CheckIfNullObject(ch, location, "No such location exists.")) { return; } if (worldCharacter != null && !worldCharacter.IsNpc()) { if (((PlayerInstance)worldCharacter).PlayerData.Flags.IsSet(PCFlags.DoNotDisturb)) { ch.PagerPrintf("Sorry. %s does not wish to be disturbed.", worldCharacter.Name); worldCharacter.PagerPrintf("Your Do-Not-Disturb flag just foiled %s's AT command.", ch.Name); return; } } if (location.IsPrivate()) { if (CheckFunctions.CheckIf(ch, () => ch.Trust < LevelConstants.GetLevel(ImmortalTypes.Greater), "That room is private right now.")) { return; } ch.SendTo("Overriding private flag!"); } CharacterInstance victim = location.IsDoNotDisturb(ch); if (victim != null) { ch.PagerPrintf("That room is \"do not disturb\" right now."); victim.PagerPrintf("Your do-not-disturb flag just foiled %s's atmob command.", ch.Name); return; } ch.SetColor(ATTypes.AT_PLAIN); RoomTemplate original = ch.CurrentRoom; ch.CurrentRoom.RemoveFrom(ch); location.AddTo(ch); interp.interpret(ch, argument); if (!ch.CharDied()) { ch.CurrentRoom.RemoveFrom(ch); original.AddTo(ch); } }
public static bool CheckAbility(CharacterInstance ch, string command, string argument, IRepositoryManager databaseManager = null) { var sn = ch.GetIDOfSkillCharacterKnows(command); if (sn == -1) { return(false); } var skill = (databaseManager ?? RepositoryManager.Instance).GetEntity <SkillData>(sn); if (skill.SkillFunction == null || skill.SpellFunction == null || ch.CanUseSkill(0, sn)) { return(false); } if (!interp.check_pos(ch, skill.MinimumPosition)) { return(true); } if (CheckFunctions.CheckIf(ch, HelperFunctions.IsCharmedOrPossessed, "For some reason, you seem unable to perform that...", new List <object> { ch })) { comm.act(ATTypes.AT_GREY, "$n wanders around aimlessly.", ch, null, null, ToTypes.Room); return(true); } //// Check if mana is required int mana = 0, blood = 0; if (skill.MinimumMana > 0) { mana = ch.IsNpc() ? 0 : skill.MinimumMana .GetHighestOfTwoNumbers(100 / (2 + ch.Level - skill.RaceLevel.ToList()[(int)ch.CurrentRace])); if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientBloodPower, "You don't have enough blood power.", new List <object> { ch, blood })) { return(true); } if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientMana, "You don't have enough mana.", new List <object> { ch, mana })) { return(true); } } DateTime start, end; //// Is this a real d-fun or just a spell? if (skill.SkillFunction == null) { CharacterInstance victim = null; ObjectInstance obj = null; var targetName = string.Empty; object vo; switch (skill.Target) { default: LogManager.Instance.Bug("Bad target to Skill {0}", sn); ch.SendTo("Something went wrong..."); return(true); case TargetTypes.Ignore: vo = null; victim = ch.GetMyTarget(); targetName = argument.IsNullOrEmpty() && victim != null ? victim.Name : argument; break; case TargetTypes.OffensiveCharacter: victim = ch.GetMyTarget(); if (argument.IsNullOrEmpty() && victim == null) { ch.Printf("Confusion overcomes you as your '%s' has no target.\r\n", skill.Name); return(true); } victim = ch.GetCharacterInRoom(argument); if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null, "They aren't here.")) { return(true); } if (fight.is_safe(ch, victim, true)) { return(true); } if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), "You can't target yourself!")) { return(true); } if (!ch.IsNpc()) { if (!victim.IsNpc()) { if (CheckFunctions.CheckIfNotNullObject(ch, ch.GetTimer(TimerTypes.PKilled), "You have been killed in the last five minutes.")) { return(true); } if (CheckFunctions.CheckIfNotNullObject(ch, victim.GetTimer(TimerTypes.PKilled), "This player has been killed in the last five minutes.")) { return(true); } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You really shouldn't do this to another player...")) { return(true); } } if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim, "You can't do that on your own follower.")) { return(true); } } if (CheckFunctions.CheckIfTrue(ch, fight.check_illegal_pk(ch, victim), "You can't do that to another player!")) { return(true); } vo = victim; break; case TargetTypes.DefensiveCharacter: victim = ch.GetCharacterInRoom(argument); if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null, "They aren't here.")) { return(true); } if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), "You can't target yourself!")) { return(true); } vo = victim; break; case TargetTypes.Self: victim = ch; vo = ch; break; case TargetTypes.InventoryObject: obj = ch.GetCarriedObject(argument); if (CheckFunctions.CheckIfNullObject(ch, obj, "You can't find that.")) { return(true); } vo = obj; break; } Macros.WAIT_STATE(ch, skill.Rounds); //// Check for failure if (SmaugRandom.D100() + skill.difficulty * 5 > (ch.IsNpc() ? 75 : Macros.LEARNED(ch, (int)skill.ID))) { ch.FailedCast(skill, victim, obj); skill.LearnFromFailure((PlayerInstance)ch); if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood / 2); } else { ch.CurrentMana -= mana / 2; } } return(true); } if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood); } else { ch.CurrentMana -= mana; } } start = DateTime.Now; var retcode = skill.SpellFunction.Value.Invoke((int)skill.ID, ch.Level, ch, vo); end = DateTime.Now; skill.UseHistory.Use(ch, end.Subtract(start)); if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.Error || ch.CharDied()) { return(true); } if (retcode == ReturnTypes.SpellFailed) { skill.LearnFromFailure((PlayerInstance)ch); retcode = ReturnTypes.None; } else { skill.AbilityLearnFromSuccess((PlayerInstance)ch); } if (skill.Target == TargetTypes.OffensiveCharacter && victim != ch && !victim.CharDied()) { if (ch.CurrentRoom.Persons.Any(vch => victim == vch && victim.CurrentFighting == null && victim.Master != ch)) { retcode = fight.multi_hit(victim, ch, Program.TYPE_UNDEFINED); } } return(true); } if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood); } else { ch.CurrentMana -= mana; } } ch.LastCommand = skill.SkillFunction; start = DateTime.Now; skill.SkillFunction.Value.Invoke(ch, argument); end = DateTime.Now; skill.UseHistory.Use(ch, end.Subtract(start)); // TODO: Tail chain? return(true); }
public static ReturnTypes spell_animate_dead(int sn, int level, CharacterInstance ch, object vo) { var corpse = ch.CurrentRoom.Contents.FirstOrDefault(x => x.ItemType == ItemTypes.NpcCorpse && x.Cost != -5); if (CheckFunctions.CheckIfNullObject(ch, corpse, "You cannot find a suitable corpse here")) { return(ReturnTypes.SpellFailed); } var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); var template = RepositoryManager.Instance.MOBILETEMPLATES.Get(VnumConstants.MOB_VNUM_ANIMATED_CORPSE); if (template == null) { throw new ObjectNotFoundException("Animated Corpse VNUM template was not found."); } // TODO Get the template using the corpse cost? huh? if (CheckFunctions.CheckIfEquivalent(ch, template, RepositoryManager.Instance.MOBILETEMPLATES.Get(VnumConstants.MOB_VNUM_DEITY), "You can't animate the corpse of a deity's Avatar.")) { return(ReturnTypes.SpellFailed); } if (!ch.IsNpc()) { if (ch.IsVampire()) { if (CheckFunctions.CheckIfTrue(ch, !ch.IsImmortal() && ((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Bloodthirsty) - template.Level / 3 < 0, "You don't have the power to reanimate this corpse.")) { return(ReturnTypes.SpellFailed); } ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, template.Level / 3); } else if (ch.CurrentMana - template.Level / 4 < 0) { ch.SendTo("You do not have enough mana to reanimate this corpse."); return(ReturnTypes.SpellFailed); } else { ch.CurrentMana -= template.Level * 4; } } if (ch.IsImmortal() || (ch.Chance(75) && template.Level - ch.Level < 10)) { return(AnimateCorpse(level, ch, template, corpse)); } ch.FailedCast(skill); return(ReturnTypes.SpellFailed); }
public static void do_murder(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfEmptyString(ch, argument, "Murder whom?")) { return; } var firstArg = argument.FirstWord(); 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 (fight.is_safe(ch, victim, true)) { return; } if (ch.IsAffected(AffectedByTypes.Charm)) { if (ch.Master == victim) { comm.act(ATTypes.AT_PLAIN, "$N is your beloeved master.", ch, null, victim, ToTypes.Character); return; } ch.Master?.Act.SetBit((int)PlayerFlags.Attacker); } if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Nice), "You feel too nice to do that!")) { return; } // TODO Log the murder Macros.WAIT_STATE(ch, 1 & GameConstants.GetSystemValue <int>("PulseViolence")); var buf = $"Help! I am being attacked by {(ch.IsNpc() ? ch.ShortDescription : ch.Name)}!"; if (victim.IsPKill()) { Wartalk.do_wartalk(victim, buf); } else { Yell.do_yell(victim, buf); } fight.check_illegal_pk(ch, victim); ch.CheckAttackForAttackerFlag(victim); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); }