9 public static bool TryShop(
Chara c,
bool realtime)
11 if (c.memberType != FactionMemberType.Guest || !
EClass._zone.IsPCFaction ||
EClass._map.props.sales.Count == 0)
16 int c_allowance = c.c_allowance;
17 if (!
EClass.debug.enable && c_allowance <= 0)
21 bool flag = card.IsContainer && card.things.Count > 0;
22 List<Card> list =
new List<Card>();
25 using (List<Thing>.Enumerator enumerator = card.things.GetEnumerator())
27 while (enumerator.MoveNext())
29 Thing thing = enumerator.Current;
40 foreach (
Card card2
in list)
43 int price = card2.GetPrice(CurrencyType.Money,
true, PriceType.PlayerShop,
null);
44 if (price >= c_allowance)
46 num = num * 10 * price / c_allowance;
52 else if (price >= 5000)
56 else if (price >= 1000)
60 else if (price >= 200)
66 if (
EClass.Branch.policies.IsActive(2817, -1))
68 num = num * (300 +
EClass.Branch.Evalue(2817)) / 100;
70 if (
EClass.Branch.policies.IsActive(2816, -1))
72 num = num * (1000 +
EClass.Branch.Evalue(2816) * 2) / 100;
85 container = (flag ? card :
null),
90 AI_Shopping.Buy(c, card2,
false, flag ? card :
null);
97 public static bool TryRestock(
Chara c,
bool realtime)
99 for (
int i = 0; i < (realtime ? 1 : 10); i++)
104 if (
EClass.rnd(2) != 0 && thing.IsInstalled)
107 if (traitSalesTag !=
null && traitSalesTag.IsOn && !thing.GetStr(11,
null).IsEmpty())
114 thing.PlaySound(
"restock", 1f,
true);
117 thing2.isSale =
true;
118 EClass._zone.AddCard(thing2, thing.pos).Install();
134 public override IEnumerable<
AIAct.Status> Run()
136 Card _dest = this.container ?? this.dest;
137 if (_dest.ExistsOnMap)
139 yield
return base.DoGoto(_dest.pos, 1,
false,
null);
141 if (!_dest.ExistsOnMap || !_dest.isSale)
143 yield
return base.Success(
null);
145 AI_Shopping.Buy(this.owner, this.dest,
true, this.container);
146 yield
return base.Success(
null);
151 public static void SellChara(
Chara c)
153 Msg.Say(
"sell_resident", c,
null,
null,
null);
154 c.homeBranch.BanishMember(c,
true);
155 EClass.player.ModKarma(-1);
159 public static void Buy(
Chara c,
Card dest,
bool realtime,
Card container)
161 Point point = dest.pos.Copy();
162 int price = dest.GetPrice(CurrencyType.Money,
true, PriceType.PlayerShop,
null);
163 if (dest.isThing && (dest.isDestroyed || dest.Thing.IsSharedContainer))
167 if (container ==
null && !dest.isSale)
171 if (container !=
null && container.c_lockLv != 0)
175 Card card = dest.isChara ? dest : dest.Split(1);
176 EClass.Branch.incomeShop += price;
180 EClass._map.props.sales.Remove(card);
184 c.Talk(
"shop_buy",
null,
null,
false);
185 c.PlaySound(
"money", 1f,
true);
186 Msg.alwaysVisible =
true;
187 Msg.Say(
"shop_buy", c, card, Lang._currency(price,
"money"),
null);
191 c.c_allowance -= price;
192 if (!c.TryUse(card.Thing))
194 card.ModNum(-1,
true);
202 else if (card.isThing)
204 card.ModNum(-1,
true);
210 if (card.isStolen || card.isChara)
212 Guild.Thief.AddContribution((
int)Mathf.Sqrt((
float)price) / 2);
214 if (container !=
null)
216 if (container.things.Count == 0)
218 container.isSale =
false;
219 EClass._map.props.sales.Remove(container);
222 else if (!dest.ExistsOnMap && dest.isThing)
226 thing.SetStr(11, dest.category.id);
227 EClass._zone.AddCard(thing, point).Install();
229 EClass.Branch.Log(
"shop_buy", c, card, Lang._currency(price,
"money"),
null);
233 public Card container;