private static void OpenObject(CharacterInstance ch, ObjectInstance obj, string arg) { if (obj.ItemType != ItemTypes.Container) { ch.Printf("%s is not a container.", obj.ShortDescription.CapitalizeFirst()); return; } if (!obj.Values.Flags.IsSet(ContainerFlags.Closed)) { ch.Printf("%s is already open.", obj.ShortDescription.CapitalizeFirst()); return; } if (!obj.Values.Flags.IsSet(ContainerFlags.Closeable)) { ch.Printf("%s cannot be opened or closed.", obj.ShortDescription.CapitalizeFirst()); return; } if (obj.Values.Flags.IsSet(ContainerFlags.Locked)) { ch.Printf("%s is locked.", obj.ShortDescription.CapitalizeFirst()); return; } obj.Values.Flags = obj.Values.Flags.RemoveBit(ContainerFlags.Closed); comm.act(ATTypes.AT_ACTION, "You open $p.", ch, obj, null, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n opens $p.", ch, obj, null, ToTypes.Room); ch.CheckObjectForTrap(obj, TrapTriggerTypes.Open); }
public static void get_obj(CharacterInstance ch, ObjectInstance obj, ObjectInstance container) { if (CheckFunctions.CheckIfTrue(ch, !obj.WearFlags.IsSet(ItemWearFlags.Take) && (ch.Level < GameManager.Instance.SystemData.GetMinimumLevel(PlayerPermissionTypes.LevelGetObjectNoTake)), "You can't take that.")) { return; } if (obj.MagicFlags.IsSet(ItemMagicFlags.PKDisarmed) && !ch.IsNpc()) { var timer = ch.GetTimer(TimerTypes.PKilled); if (ch.CanPKill() && timer == null) { if (ch.Level - obj.Value.ToList()[5] > 5 || obj.Value.ToList()[5] - ch.Level > 5) { ch.SendTo("\r\n&bA godly force freezes your outstretched hand."); return; } obj.MagicFlags.RemoveBit(ItemMagicFlags.PKDisarmed); obj.Value.ToList()[5] = 0; } } else { ch.SendTo("\r\n&BA godly force freezes your outstretched hand."); return; } if (CheckFunctions.CheckIfTrue(ch, obj.ExtraFlags.IsSet((int)ItemExtraFlags.Prototype) && !ch.CanTakePrototype(), "A godly force prevents you from getting close to it.")) { return; } if (ch.CarryNumber + obj.ObjectNumber > ch.CanCarryN()) { comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that many items.", ch, null, obj.ShortDescription, ToTypes.Character); return; } var weight = obj.ExtraFlags.IsSet((int)ItemExtraFlags.Covering) ? obj.Weight : obj.GetWeight(); if (obj.ItemType != ItemTypes.Money) { if (obj.InObject != null) { var tObject = obj.InObject; var inobj = 1; var checkweight = tObject.ItemType == ItemTypes.Container && tObject.ExtraFlags.IsSet((int)ItemExtraFlags.Magical); while (tObject.InObject != null) { tObject = tObject.InObject; inobj++; checkweight = tObject.ItemType == ItemTypes.Container && tObject.ExtraFlags.IsSet((int)ItemExtraFlags.Magical); } if (tObject.CarriedBy == null || tObject.CarriedBy != ch || checkweight) { if (ch.CarryWeight + weight > ch.CanCarryMaxWeight()) { comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that much weight.", ch, null, obj.ShortDescription, ToTypes.Character); return; } } } else if (ch.CarryWeight + weight > ch.CanCarryMaxWeight()) { comm.act(ATTypes.AT_PLAIN, "$d: you can't carry that much weight.", ch, null, obj.ShortDescription, ToTypes.Character); return; } } if (container != null) { GetObjectFromContainer(ch, obj, container); } else { GetObjectFromRoom(ch, obj); } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom) && (container?.CarriedBy == null)) { foreach (var clan in RepositoryManager.Instance.CLANS.Values) { if (clan.StoreRoom == ch.CurrentRoom.ID) { save_clan_storeroom(ch, clan); } } } if (obj.ItemType != ItemTypes.Container) { ch.CheckObjectForTrap(obj, TrapTriggerTypes.Get); } if (ch.CharDied()) { return; } if (obj.ItemType == ItemTypes.Money) { int amt = obj.Values.NumberOfCoins * obj.Count; ch.CurrentCoin += amt; obj.Extract(); } else { obj = obj.AddTo(ch); } if (ch.CharDied() || handler.obj_extracted(obj)) { return; } MudProgHandler.ExecuteObjectProg(MudProgTypes.Get, ch, obj); }