Elin Decompiled Documentation EA 23.224 Nightly
Loading...
Searching...
No Matches
FoodEffect.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class FoodEffect : EClass
5{
6 public static bool IsLeftoverable(Thing food)
7 {
8 return food.trait is TraitLunch;
9 }
10
11 public static void Proc(Chara c, Thing food, bool consume = true)
12 {
13 food.CheckJustCooked();
14 bool flag = EClass._zone.IsPCFaction && c.IsInSpot<TraitSpotDining>();
15 int num = (food.isCrafted ? ((EClass.pc.Evalue(1650) >= 3) ? 5 : 0) : 0);
16 float num2 = (float)(100 + (food.HasElement(757) ? 10 : 0) + (flag ? 10 : 0) + num + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
17 if (num2 < 0.1f)
18 {
19 num2 = 0.1f;
20 }
21 int num3 = Mathf.Clamp(food.Evalue(10), 0, 10000);
22 float num4 = 25f;
23 float num5 = 1f;
24 string idTaste = "";
25 bool flag2 = food.HasElement(708);
26 bool flag3 = food.HasElement(709);
27 bool flag4 = c.HasElement(1205);
28 bool flag5 = food.IsDecayed || flag3;
29 bool flag6 = IsLeftoverable(food);
31 if (c.IsPCFaction && !c.IsPC)
32 {
33 int num6 = c.CountNumEaten(food);
34 bool flag7 = c.GetFavFood().id == food.id;
35 if (num6 < 2 || flag7)
36 {
37 if (num6 == 1 || flag7 || EClass.rnd(4) == 0)
38 {
39 c.Talk("foodNice");
40 }
41 }
42 else if (num6 > 3 && EClass.rnd(num6) >= 3)
43 {
44 c.Talk("foodBored");
45 }
46 }
47 if (food.IsBlessed)
48 {
49 num2 *= 1.5f;
50 }
51 if (food.IsCursed)
52 {
53 num2 *= 0.5f;
54 }
55 if (flag4)
56 {
57 if (flag2)
58 {
59 num5 *= 2f;
60 num2 *= 1.5f;
61 }
62 else
63 {
64 num5 *= 0.5f;
65 num2 /= 2f;
66 num3 /= 2;
67 }
68 }
69 else if (flag2)
70 {
71 num5 = 0f;
72 num2 *= 0.5f;
73 }
74 if (c.HasElement(1200))
75 {
76 num2 *= 1.25f;
77 }
78 if (!c.IsPC)
79 {
80 num2 *= 3f;
81 }
82 if (flag5 && !c.HasElement(480))
83 {
84 if (c.IsPC)
85 {
86 if (flag3)
87 {
88 c.Say("food_undead");
89 }
90 c.Say("food_rot");
91 }
92 num5 = 0f;
93 num3 /= 2;
94 }
95 else
96 {
97 switch (food.source._origin)
98 {
99 case "meat":
100 if (c.IsPC)
101 {
102 c.Say("food_raw_meat");
103 }
104 num2 *= 0.7f;
105 num5 = 0.5f;
106 break;
107 case "fish":
108 if (c.IsHuman)
109 {
110 if (c.IsPC)
111 {
112 c.Say("food_raw_fish");
113 }
114 num2 *= 0.9f;
115 num5 = 0.5f;
116 }
117 break;
118 case "dough":
119 if (c.IsPC)
120 {
121 c.Say("food_raw_powder");
122 }
123 num2 *= 0.9f;
124 num5 = 0.5f;
125 break;
126 }
127 }
128 float num7 = Mathf.Min(c.hunger.value, num3);
129 if (c.hunger.GetPhase() >= 3)
130 {
131 num7 *= 1.1f;
132 }
133 if (flag5 && !c.HasElement(480))
134 {
135 c.ModExp(70, -300);
136 c.ModExp(71, -300);
137 c.ModExp(72, -200);
138 c.ModExp(73, -200);
139 c.ModExp(74, -200);
140 c.ModExp(75, 500);
141 c.ModExp(76, -200);
142 c.ModExp(77, -300);
143 }
144 else
145 {
146 num2 = num2 * num7 / 10f;
147 if (c.HasCondition<ConAnorexia>())
148 {
149 num2 = 0.01f;
150 }
151 List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
152 foreach (Element value in food.elements.dict.Values)
153 {
154 if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
155 {
156 continue;
157 }
158 string[] foodEffect = value.source.foodEffect;
159 int id = value.id;
160 float num8 = num2 * (float)value.Value;
161 if (value.source.category == "food" && c.IsPC)
162 {
163 bool flag8 = num8 >= 0f;
164 string text = value.source.GetText(flag8 ? "textInc" : "textDec", returnNull: true);
165 if (text != null)
166 {
167 Msg.SetColor(flag8 ? "positive" : "negative");
168 c.Say(text);
169 }
170 }
171 switch (foodEffect[0])
172 {
173 case "god":
174 {
175 int int2 = c.GetInt(117);
176 if (int2 < 10)
177 {
178 foreach (Element value2 in c.elements.dict.Values)
179 {
180 if (value2.IsMainAttribute)
181 {
182 c.elements.ModPotential(value2.id, 2);
183 }
184 }
185 }
186 c.Say("little_eat", c);
187 c.PlaySound("ding_potential");
188 c.elements.ModExp(306, -1000f);
189 c.SetInt(117, int2 + 1);
190 flag6 = false;
191 break;
192 }
193 case "exp":
194 {
195 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
196 int a = (int)(num8 * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
197 c.ModExp(id, a);
198 break;
199 }
200 case "pot":
201 {
202 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
203 int vTempPotential = c.elements.GetElement(id).vTempPotential;
204 int num9 = EClass.rndHalf((int)(num8 / 5f) + 1);
205 num9 = num9 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
206 c.elements.ModTempPotential(id, num9, 8);
207 break;
208 }
209 case "karma":
210 if (c.IsPCParty)
211 {
213 }
214 break;
215 case "poison":
216 ActEffect.Poison(c, EClass.pc, value.Value * 10);
217 if (!c.isDead)
218 {
219 break;
220 }
221 goto IL_0f01;
222 case "love":
223 ActEffect.LoveMiracle(c, EClass.pc, value.Value * 10);
224 break;
225 case "loseWeight":
226 c.ModWeight(-EClass.rndHalf(value.Value), ignoreLimit: true);
227 break;
228 case "gainWeight":
229 c.ModWeight(EClass.rndHalf(value.Value), ignoreLimit: true);
230 break;
231 case "little":
232 {
233 int @int = c.GetInt(112);
234 if (@int < 30)
235 {
236 c.Say("little_eat", c);
237 c.PlaySound("ding_potential");
238 int v = Mathf.Max(5 - @int / 2, 1);
239 Debug.Log("sister eaten:" + @int + "/" + v);
240 foreach (Element value3 in c.elements.dict.Values)
241 {
242 if (value3.IsMainAttribute)
243 {
244 c.elements.ModPotential(value3.id, v);
245 }
246 }
247 }
248 if (c.race.id == "mutant" && c.elements.Base(1230) < 10)
249 {
250 c.Say("little_adam", c);
251 c.SetFeat(1230, c.elements.Base(1230) + 1);
252 }
253 c.SetInt(112, @int + 1);
254 break;
255 }
256 }
257 }
258 }
259 ProcTrait(c, food);
260 num4 += (float)food.Evalue(70);
261 num4 += (float)(food.Evalue(72) / 2);
262 num4 += (float)(food.Evalue(73) / 2);
263 num4 += (float)(food.Evalue(75) / 2);
264 num4 += (float)(food.Evalue(76) * 3 / 2);
265 num4 += (float)food.Evalue(440);
266 num4 += (float)(food.Evalue(445) / 2);
267 num4 -= (float)food.Evalue(71);
268 num4 += (float)(num3 / 2);
269 num4 *= num5;
270 if (idTaste.IsEmpty())
271 {
272 if (num4 > 100f)
273 {
274 idTaste = "food_great";
275 }
276 else if (num4 > 70f)
277 {
278 idTaste = "food_good";
279 }
280 else if (num4 > 50f)
281 {
282 idTaste = "food_soso";
283 }
284 else if (num4 > 30f)
285 {
286 idTaste = "food_average";
287 }
288 else
289 {
290 idTaste = "food_bad";
291 }
292 if (c.IsPC)
293 {
294 c.Say(idTaste);
295 if (flag2)
296 {
297 c.Say(flag4 ? "food_human_pos" : "food_human_neg");
298 }
299 else if (flag4)
300 {
301 c.Say("food_human_whine");
302 }
303 }
304 }
305 if (LangGame.Has(idTaste + "2"))
306 {
307 c.Say(idTaste + "2", c, food);
308 }
309 if (!c.IsPCParty)
310 {
311 num3 *= 2;
312 }
313 num3 = num3 * (100 + c.Evalue(1235) * 10) / (100 + c.Evalue(1234) * 10 + c.Evalue(1236) * 15);
314 c.hunger.Mod(-num3);
315 if (flag2)
316 {
317 if (!flag4)
318 {
319 if (c.IsHuman)
320 {
321 c.AddCondition<ConInsane>(200);
322 c.SAN.Mod(15);
323 }
324 if (EClass.rnd(c.IsHuman ? 5 : 20) == 0)
325 {
326 c.SetFeat(1205, 1, msg: true);
327 flag4 = true;
328 }
329 }
330 if (flag4)
331 {
332 c.SetInt(31, EClass.world.date.GetRaw() + 10080);
333 }
334 }
335 else if (flag4 && c.GetInt(31) < EClass.world.date.GetRaw())
336 {
337 c.SetFeat(1205, 0, msg: true);
338 }
339 if (flag5 && !c.HasElement(480))
340 {
342 c.AddCondition<ConConfuse>(200);
343 }
344 if (c.HasCondition<ConAnorexia>())
345 {
346 c.Vomit();
347 }
348 if (num3 > 20 && c.HasElement(1413))
349 {
350 Thing thing = ThingGen.Create("seed");
351 if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0)
352 {
353 TraitSeed.ApplySeed(thing, (EClass.rnd(4) == 0) ? 118 : ((EClass.rnd(3) == 0) ? 119 : 90));
354 }
355 thing.SetNum(2 + EClass.rnd(3));
356 c.Talk("vomit");
357 c.Say("fairy_vomit", c, thing);
358 c.PickOrDrop(c.pos, thing);
359 }
360 food.trait.OnEat(c);
361 if (food.trait is TraitDrink)
362 {
363 food.trait.OnDrink(c);
364 }
365 goto IL_0f01;
366 IL_0f01:
367 if (!consume)
368 {
369 return;
370 }
371 num7 += 5f;
372 if (flag6 && (float)food.Evalue(10) > num7 + 10f)
373 {
374 food.elements.SetTo(10, (int)Mathf.Max((float)food.Evalue(10) - num7, 1f));
375 food.SetBool(125, enable: true);
376 if (food.HasElement(1229))
377 {
378 food.elements.Remove(1229);
379 }
380 }
381 else
382 {
383 food.ModNum(-1);
384 }
385 }
386
387 public static void ProcTrait(Chara c, Card t)
388 {
389 bool flag = false;
390 foreach (Element value in t.elements.dict.Values)
391 {
392 if (!value.IsTrait)
393 {
394 continue;
395 }
396 if (value.Value >= 0)
397 {
398 switch (value.id)
399 {
400 case 753:
401 c.CureCondition<ConPoison>(value.Value * 2);
402 break;
403 case 754:
404 c.AddCondition<ConPeace>(value.Value * 5);
405 break;
406 case 755:
407 c.CureCondition<ConBleed>(value.Value);
408 break;
409 case 756:
410 c.AddCondition<ConHotspring>(value.Value * 2)?.SetPerfume();
411 break;
412 case 760:
413 if (!c.HasCondition<ConAwakening>())
414 {
415 flag = true;
416 }
417 c.AddCondition<ConAwakening>(1000 + value.Value * 20);
418 break;
419 case 761:
420 if (c.HasCondition<ConAwakening>() && !flag)
421 {
422 if (c.IsPC)
423 {
424 Msg.Say("recharge_stamina_fail");
425 }
426 }
427 else
428 {
429 c.Say("recharge_stamina", c);
430 c.stamina.Mod(c.stamina.max * (value.Value / 10 + 1) / 100 + value.Value * 2 / 3 + EClass.rnd(5));
431 }
432 break;
433 }
434 }
435 else
436 {
437 switch (value.id)
438 {
439 case 753:
440 SayTaste("food_poison");
441 c.AddCondition<ConPoison>(-value.Value * 10);
442 break;
443 case 754:
444 SayTaste("food_mind");
445 c.AddCondition<ConConfuse>(-value.Value * 10);
446 c.AddCondition<ConInsane>(-value.Value * 10);
447 c.AddCondition<ConHallucination>(-value.Value * 20);
448 break;
449 case 755:
450 c.AddCondition<ConBleed>(-value.Value * 10);
451 break;
452 case 756:
453 c.hygiene.Mod(-value.Value * 5);
454 break;
455 case 760:
456 c.RemoveCondition<ConAwakening>();
457 c.sleepiness.Mod(value.Value);
458 break;
459 case 761:
460 c.Say("recharge_stamina_negative", c);
461 c.stamina.Mod(-c.stamina.max * (-value.Value / 10 + 1) / 100 + value.Value);
462 break;
463 }
464 }
465 }
466 void SayTaste(string _id)
467 {
468 if (c.IsPC)
469 {
470 c.Say(_id);
471 }
472 }
473 }
474}
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
static void Poison(Chara tc, Chara c, int power)
Definition: ActEffect.cs:2566
static void LoveMiracle(Chara tc, Chara c, int power, EffectId idEffect=EffectId.Love, BlessedState? state=null)
Definition: ActEffect.cs:2582
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
void Mod(int a, bool force=false)
Definition: Card.cs:11
ElementContainerCard elements
Definition: Card.cs:41
bool HasElement(int ele, int req=1)
Definition: Card.cs:5787
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6009
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6564
Thing SetNum(int a)
Definition: Card.cs:3425
Point pos
Definition: Card.cs:59
int Evalue(int ele)
Definition: Card.cs:2559
void ModExp(string alias, int a)
Definition: Card.cs:2636
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6661
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8994
override bool IsPC
Definition: Chara.cs:610
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9594
override bool IsPCParty
Definition: Chara.cs:613
bool HasCondition(string alias)
Definition: Chara.cs:9151
Stats hunger
Definition: Chara.cs:1136
bool IsHuman
Definition: Chara.cs:877
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4211
override bool IsPCFaction
Definition: Chara.cs:669
void Vomit()
Definition: Chara.cs:5155
Stats SAN
Definition: Chara.cs:1152
SourceThing.Row GetFavFood()
Definition: Chara.cs:7830
void ModWeight(int a, bool ignoreLimit=false)
Definition: Chara.cs:9511
void AddFoodHistory(Thing food)
Definition: Chara.cs:9860
int CountNumEaten(Thing food)
Definition: Chara.cs:9880
bool isDead
Definition: Chara.cs:387
SourceRace.Row race
Definition: Chara.cs:462
bool enable
Definition: CoreDebug.cs:286
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static World world
Definition: EClass.cs:40
static int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static int rndHalf(int a)
Definition: EClass.cs:87
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
void ModExp(int ele, float a, bool chain=false)
Dictionary< int, Element > dict
Element ModPotential(int ele, int v)
Element ModTempPotential(int ele, int v, int threshMsg=0)
Element GetElement(string alias)
int id
Definition: ELEMENT.cs:250
SourceElement.Row source
Definition: ELEMENT.cs:273
int vTempPotential
Definition: ELEMENT.cs:258
int Value
Definition: ELEMENT.cs:292
bool IsTrait
Definition: ELEMENT.cs:362
bool IsMainAttribute
Definition: ELEMENT.cs:383
static bool IsLeftoverable(Thing food)
Definition: FoodEffect.cs:6
static void ProcTrait(Chara c, Card t)
Definition: FoodEffect.cs:387
static void Proc(Chara c, Thing food, bool consume=true)
Definition: FoodEffect.cs:11
static bool Has(string id)
Definition: LangGame.cs:46
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
static void SetColor()
Definition: Msg.cs:22
void ModKarma(int a)
Definition: Player.cs:2496
SourceElement elements
virtual void Mod(int a)
Definition: Stats.cs:135
override int GetPhase()
Definition: Stats.cs:117
virtual int value
Definition: Stats.cs:56
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
static Thing ApplySeed(Thing t, int refval)
Definition: TraitSeed.cs:174
GameDate date
Definition: World.cs:6