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); } }
public static void appraise_all(CharacterInstance ch, MobileInstance keeper, string fixstr) { int total = 0, cost = 0; string buffer; foreach (var obj in ch.Carrying.Where(obj => obj.WearLocation == WearLocations.None && ch.CanSee(obj) && (obj.ItemType.GetAttribute <ValuedAttribute>() != null))) { if (!ch.CanDrop(obj)) { ch.Printf("You can't let go of %s.", obj.Name); continue; } if ((cost = Appraise.GetAdjustedRepairCost(keeper, obj)) > 0) { comm.act(ATTypes.AT_TELL, cost != -2 ? "$n tells you, 'Sorry, I can't do anything with $p.'" : "$n tells you, '$p looks fine to me!'", keeper, obj, ch, ToTypes.Victim); continue; } buffer = $"$N tells you, 'It will cost {cost} piece{(cost == 1 ? "" : "s")} of gold to {fixstr} {obj.Name}.'"; comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character); total += cost; } if (total <= 0) { return; } ch.SendTo("\r\n"); buffer = $"$N tells you, 'It will cost {total} piece{(cost == 1 ? "" : "s")} of gold in total.'"; comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character); comm.act(ATTypes.AT_TELL, "$N tells you, 'Remember there is a 10% surcharge for repairing all your items.", ch, null, keeper, ToTypes.Character); }
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 static void repair_one_obj(CharacterInstance ch, MobileInstance keeper, ObjectInstance obj, string arg, int maxgold, string fixstr, string fixstr2) { int cost; string buffer; if (!ch.CanDrop(obj)) { ch.Printf("You can't let go of %s.\r\n", obj.Name); } else if ((cost = Appraise.GetAdjustedRepairCost(keeper, obj)) < 0) { if (cost < 0) { comm.act(ATTypes.AT_TELL, cost != -2 ? "$n tells you, 'Sorry, I can't do anything with $p.'" : "$n tells you, '$p looks fine to me!'", keeper, obj, ch, ToTypes.Victim); } } // repair all gets a 10% surcharge else if ((cost = arg.Equals("all") ? cost : 11 * (cost / 10)) > ch.CurrentCoin) { buffer = $"$N tells you, 'It will cost {cost} piece{(cost == 1 ? "" : "s")} of gold to {fixstr} {obj.Name}...'"; comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character); comm.act(ATTypes.AT_TELL, "$n tells you, 'Which I see you can't afford.'", ch, null, keeper, ToTypes.Character); } else { buffer = $"$n gives $p to $N, who quickly {fixstr2} it."; comm.act(ATTypes.AT_ACTION, buffer, ch, obj, keeper, ToTypes.Room); buffer = $"$n charges you {cost} gold piece{(cost == 1 ? "" : "s")} to {fixstr} $p."; comm.act(ATTypes.AT_ACTION, buffer, ch, obj, keeper, ToTypes.Character); ch.CurrentCoin -= cost; keeper.CurrentCoin += cost; if (keeper.CurrentCoin < 0) { keeper.CurrentCoin = 0; } else if (keeper.CurrentCoin > maxgold) { keeper.CurrentRoom.Area.BoostEconomy(keeper.CurrentCoin - maxgold / 2); keeper.CurrentCoin = maxgold / 2; comm.act(ATTypes.AT_ACTION, "$n puts some gold into a large safe.", keeper, null, null, ToTypes.Room); } switch (obj.ItemType) { default: ch.SendTo("For some reason, you think you got ripped off..."); break; case ItemTypes.Armor: obj.Values.CurrentAC = obj.Values.OriginalAC; break; case ItemTypes.Weapon: obj.Values.Condition = GameConstants.GetConstant <int>("InitWeaponCondition"); break; case ItemTypes.Wand: case ItemTypes.Staff: obj.Values.Charges = obj.Values.MaxCharges; break; } MudProgHandler.ExecuteObjectProg(MudProgTypes.Repair, ch, obj); } }