Elin Decompiled Documentation EA 23.321 Nightly Patch 1
Loading...
Searching...
No Matches
FoodEffect.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4
5public class FoodEffect : EClass
6{
7 public static bool IsLeftoverable(Thing food)
8 {
9 if (food.HasElement(758) || food.HasElement(1229))
10 {
11 return false;
12 }
13 return food.trait is TraitLunch;
14 }
15
16 public static void Proc(Chara c, Thing food, bool consume = true)
17 {
18 if (food.id == "bloodsample")
19 {
20 food.ModNum(-1);
21 return;
22 }
23 food.CheckJustCooked();
24 bool flag = EClass._zone.IsPCFactionOrTent && c.IsInSpot<TraitSpotDining>();
25 int num = (food.isCrafted ? ((EClass.pc.Evalue(1650) >= 3) ? 5 : 0) : 0);
26 float num2 = (float)(100 + (food.HasElement(757) ? 10 : 0) + (flag ? 10 : 0) + num + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
27 if (num2 < 0.1f)
28 {
29 num2 = 0.1f;
30 }
31 int num3 = Mathf.Clamp(food.Evalue(10), 0, 10000);
32 float num4 = 25f;
33 float num5 = 1f;
34 string idTaste = "";
35 bool flag2 = food.HasElement(708);
36 bool flag3 = food.HasElement(709);
37 bool flag4 = c.HasElement(1205);
38 bool flag5 = food.IsDecayed || flag3;
39 bool flag6 = IsLeftoverable(food);
40 bool flag7 = EClass._zone.HasField(10001) && food.GetBool(128);
42 if (c.IsPCFaction && !c.IsPC)
43 {
44 int num6 = c.CountNumEaten(food);
45 bool flag8 = c.GetFavFood().id == food.id;
46 if (num6 < 2 || flag8)
47 {
48 if (num6 == 1 || flag8 || EClass.rnd(4) == 0)
49 {
50 c.Talk("foodNice");
51 }
52 }
53 else if (num6 > 3 && EClass.rnd(num6) >= 3)
54 {
55 c.Talk("foodBored");
56 }
57 }
58 if (food.IsBlessed)
59 {
60 num2 *= 1.5f;
61 }
62 if (food.IsCursed)
63 {
64 num2 *= 0.5f;
65 }
66 if (flag4)
67 {
68 if (flag2)
69 {
70 num5 *= 2f;
71 num2 *= 1.3f;
72 }
73 else
74 {
75 num5 *= 0.5f;
76 num2 /= 2f;
77 num3 /= 2;
78 }
79 }
80 else if (flag2)
81 {
82 num5 = 0f;
83 num2 *= 0.5f;
84 }
85 if (c.HasElement(1250))
86 {
87 if (food.HasElement(710))
88 {
89 num2 = num2 * 0.1f * (float)(food.Evalue(710) + 10);
90 }
91 else
92 {
93 num3 /= 10;
94 }
95 }
96 if (c.HasElement(1200))
97 {
98 num2 *= 1f + (float)c.Evalue(1200) * 0.3f;
99 }
100 if (!c.IsPC)
101 {
102 num2 *= 3f;
103 }
104 if (flag5 && !c.HasElement(480))
105 {
106 if (c.IsPC)
107 {
108 if (flag3)
109 {
110 c.Say("food_undead");
111 }
112 c.Say("food_rot");
113 }
114 num5 = 0f;
115 num3 /= 2;
116 }
117 else
118 {
119 switch (food.source._origin)
120 {
121 case "meat":
122 if (c.IsPC)
123 {
124 c.Say("food_raw_meat");
125 }
126 num2 *= 0.7f;
127 num5 = 0.5f;
128 break;
129 case "fish":
130 if (c.IsHuman)
131 {
132 if (c.IsPC)
133 {
134 c.Say("food_raw_fish");
135 }
136 num2 *= 0.9f;
137 num5 = 0.5f;
138 }
139 break;
140 case "dough":
141 if (c.IsPC)
142 {
143 c.Say("food_raw_powder");
144 }
145 num2 *= 0.9f;
146 num5 = 0.5f;
147 break;
148 }
149 }
150 float num7 = (flag7 ? num3 : Mathf.Min(c.hunger.value, num3));
151 if (c.hunger.GetPhase() >= 3)
152 {
153 num7 *= 1.1f;
154 }
155 ProcNutrition(c, food, num2, num7);
156 if (!c.isDead)
157 {
158 ProcTrait(c, food);
159 if (!c.isDead)
160 {
161 num4 += (float)food.Evalue(70);
162 num4 += (float)(food.Evalue(72) / 2);
163 num4 += (float)(food.Evalue(73) / 2);
164 num4 += (float)(food.Evalue(75) / 2);
165 num4 += (float)(food.Evalue(76) * 3 / 2);
166 num4 += (float)food.Evalue(440);
167 num4 += (float)(food.Evalue(445) / 2);
168 num4 -= (float)food.Evalue(71);
169 num4 += (float)food.Evalue(18);
170 num4 += (float)(num3 / 2);
171 num4 *= num5;
172 if (idTaste.IsEmpty())
173 {
174 if (num4 > 100f)
175 {
176 idTaste = "food_great";
177 }
178 else if (num4 > 70f)
179 {
180 idTaste = "food_good";
181 }
182 else if (num4 > 50f)
183 {
184 idTaste = "food_soso";
185 }
186 else if (num4 > 30f)
187 {
188 idTaste = "food_average";
189 }
190 else
191 {
192 idTaste = "food_bad";
193 }
194 if (c.IsPC)
195 {
196 c.Say(idTaste);
197 if (flag2)
198 {
199 c.Say(flag4 ? "food_human_pos" : "food_human_neg");
200 }
201 else if (flag4)
202 {
203 c.Say("food_human_whine");
204 }
205 }
206 }
207 if (LangGame.Has(idTaste + "2"))
208 {
209 c.Say(idTaste + "2", c, food);
210 }
211 if (!c.IsPCParty)
212 {
213 num3 *= 2;
214 }
215 num3 = num3 * (100 + c.Evalue(1235) * 10) / (100 + c.Evalue(1234) * 10 + c.Evalue(1236) * 15);
216 c.hunger.Mod(-num3);
217 if (flag2)
218 {
219 if (!flag4)
220 {
221 if (c.IsHuman)
222 {
223 c.AddCondition<ConInsane>(200);
224 c.SAN.Mod(15);
225 }
226 if (EClass.rnd(c.IsHuman ? 5 : 20) == 0)
227 {
228 c.SetFeat(1205, 1, msg: true);
229 flag4 = true;
230 }
231 }
232 if (flag4)
233 {
234 c.SetInt(31, EClass.world.date.GetRaw() + 10080);
235 }
236 }
237 else if (flag4 && c.GetInt(31) < EClass.world.date.GetRaw())
238 {
239 c.SetFeat(1205, 0, msg: true);
240 }
241 if (flag5 && !c.HasElement(480))
242 {
244 c.AddCondition<ConConfuse>(200);
245 }
246 if (c.HasCondition<ConAnorexia>())
247 {
248 c.Vomit();
249 }
250 if (num3 > 20 && c.HasElement(1413))
251 {
252 Thing thing = ThingGen.Create("seed");
253 if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0)
254 {
255 TraitSeed.ApplySeed(thing, (EClass.rnd(4) == 0) ? 118 : ((EClass.rnd(3) == 0) ? 119 : 90));
256 }
257 thing.SetNum(2 + EClass.rnd(3));
258 c.Talk("vomit");
259 c.Say("fairy_vomit", c, thing);
260 c.PickOrDrop(c.pos, thing);
261 }
262 food.trait.OnEat(c);
263 }
264 }
265 if (consume)
266 {
267 num7 += 5f;
268 if (flag6 && (float)food.Evalue(10) > num7 + 10f)
269 {
270 food.elements.SetTo(10, (int)Mathf.Max((float)food.Evalue(10) - num7, 1f));
271 food.SetBool(125, enable: true);
272 if (food.HasElement(1229))
273 {
274 food.elements.Remove(1229);
275 }
276 }
277 else
278 {
279 food.ModNum(-1);
280 }
281 }
282 if (c.isDead)
283 {
284 return;
285 }
286 if (!c.IsCat && food.trait is TraitFoodChuryu)
287 {
288 int num8 = 0;
289 foreach (Chara item in c.pos.ListCharasInRadius(c, 5, (Chara c) => c.IsCat))
290 {
291 item.Say("angry", item);
292 item.ShowEmo(Emo.angry);
293 item.PlaySound("Animal/Cat/cat_angry");
294 if (c.IsPC)
295 {
297 }
298 num8++;
299 }
300 EClass.player.stats.angryCats += num8;
301 Debug.Log(num8 + "/" + EClass.player.stats.angryCats);
302 if (num8 >= 10)
303 {
305 }
306 }
307 if (c.IsPC && EClass._zone is Zone_Lothria)
308 {
309 switch (food.id)
310 {
311 case "681":
312 case "pie_meat":
313 case "pie_fish":
315 break;
316 }
317 }
318 if (!(food.trait is TraitGene) || !c.HasElement(1274))
319 {
320 return;
321 }
322 DNA c_DNA = food.c_DNA;
323 int slot = c_DNA.slot;
324 CharaGenes genes = c.c_genes;
325 int excess = c.CurrentGeneSlot + slot - c.MaxGeneSlot;
326 switch (c_DNA.type)
327 {
328 case DNA.Type.Inferior:
329 if (genes != null)
330 {
331 RemoveDNA(fromOldest: false);
332 }
333 return;
334 case DNA.Type.Brain:
335 if (genes != null)
336 {
337 genes.items.Shuffle();
338 Msg.Say("reconstruct", c);
339 c.Say("food_mind", c);
341 }
342 return;
343 }
344 if (excess > 0)
345 {
346 while (excess > 0 && genes != null && genes.items.Count != 0)
347 {
348 RemoveDNA(fromOldest: true);
349 }
350 }
351 c_DNA.Apply(c);
352 c.Say("little_eat", c);
353 c.PlaySound("ding_potential");
354 SE.Play("mutation");
355 c.PlayEffect("identify");
356 void RemoveDNA(bool fromOldest)
357 {
358 DNA dNA = (fromOldest ? genes.items[0] : genes.items.Last());
359 CharaGenes.Remove(c, dNA);
360 excess -= dNA.slot;
361 }
362 }
363
364 public static void ProcDrink(Chara c, Thing food)
365 {
366 int num = Mathf.Max(1, food.Evalue(10));
367 float num2 = (float)(100 + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
368 if (num2 < 0.1f)
369 {
370 num2 = 0.1f;
371 }
372 if (c.hunger.GetPhase() <= 0)
373 {
374 num = 0;
375 }
376 c.hunger.Mod(-num);
377 ProcNutrition(c, food, num2, num);
378 if (!c.isDead)
379 {
380 ProcTrait(c, food);
381 }
382 if (!c.isDead)
383 {
384 food.trait.OnDrink(c);
385 }
386 }
387
388 public static void ProcNutrition(Chara c, Thing food, float effP, float validFill)
389 {
390 bool flag = food.HasElement(709);
391 if ((food.IsDecayed || flag) && !c.HasElement(480))
392 {
393 c.ModExp(70, -300);
394 c.ModExp(71, -300);
395 c.ModExp(72, -200);
396 c.ModExp(73, -200);
397 c.ModExp(74, -200);
398 c.ModExp(75, 500);
399 c.ModExp(76, -200);
400 c.ModExp(77, -300);
401 return;
402 }
403 effP = effP * validFill / 10f;
404 if (c.HasCondition<ConAnorexia>())
405 {
406 effP = 0.01f;
407 }
408 List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
409 foreach (Element value in food.elements.dict.Values)
410 {
411 if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
412 {
413 continue;
414 }
415 string[] foodEffect = value.source.foodEffect;
416 int id = value.id;
417 float num = effP * (float)value.Value;
418 if (value.source.category == "food" && c.IsPC)
419 {
420 bool flag2 = num >= 0f;
421 string text = value.source.GetText(flag2 ? "textInc" : "textDec", returnNull: true);
422 if (text != null)
423 {
424 Msg.SetColor(flag2 ? "positive" : "negative");
425 c.Say(text);
426 }
427 }
428 switch (foodEffect[0])
429 {
430 case "god":
431 {
432 int int2 = c.GetInt(117);
433 if (int2 < 10)
434 {
435 foreach (Element value2 in c.elements.dict.Values)
436 {
437 if (value2.IsMainAttribute)
438 {
439 c.elements.ModPotential(value2.id, 2);
440 }
441 }
442 }
443 c.Say("little_eat", c);
444 c.PlaySound("ding_potential");
445 c.elements.ModExp(306, -1000f);
446 c.SetInt(117, int2 + 1);
447 break;
448 }
449 case "exp":
450 {
451 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
452 int a = (int)(num * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
453 c.ModExp(id, a);
454 break;
455 }
456 case "pot":
457 {
458 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
459 int vTempPotential = c.elements.GetElement(id).vTempPotential;
460 int num2 = EClass.rndHalf((int)(num / 5f) + 1);
461 num2 = num2 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
462 c.elements.ModTempPotential(id, num2, 8);
463 break;
464 }
465 case "karma":
466 if (c.IsPCParty)
467 {
469 }
470 break;
471 case "poison":
472 ActEffect.Poison(c, EClass.pc, value.Value * 10);
473 break;
474 case "love":
475 ActEffect.LoveMiracle(c, EClass.pc, value.Value * 10);
476 break;
477 case "loseWeight":
478 c.ModWeight(-EClass.rndHalf(value.Value), ignoreLimit: true);
479 break;
480 case "gainWeight":
481 c.ModWeight(EClass.rndHalf(value.Value), ignoreLimit: true);
482 break;
483 case "little":
484 {
485 int @int = c.GetInt(112);
486 if (@int < 30)
487 {
488 c.Say("little_eat", c);
489 c.PlaySound("ding_potential");
490 int v = Mathf.Max(5 - @int / 2, 1);
491 Debug.Log("sister eaten:" + @int + "/" + v);
492 foreach (Element value3 in c.elements.dict.Values)
493 {
494 if (value3.IsMainAttribute)
495 {
496 c.elements.ModPotential(value3.id, v);
497 }
498 }
499 }
500 if (c.race.id == "mutant" && c.elements.Base(1230) < 10)
501 {
502 c.Say("little_adam", c);
503 c.SetFeat(1230, c.elements.Base(1230) + 1);
504 }
505 c.SetInt(112, @int + 1);
506 break;
507 }
508 }
509 }
510 }
511
512 public static void ProcTrait(Chara c, Card food)
513 {
514 bool flag = false;
515 foreach (Element value in food.elements.dict.Values)
516 {
517 if (!value.IsTrait)
518 {
519 continue;
520 }
521 if (value.Value >= 0)
522 {
523 switch (value.id)
524 {
525 case 753:
526 c.CureCondition<ConPoison>(value.Value * 2);
527 break;
528 case 754:
529 c.AddCondition<ConPeace>(value.Value * 5);
530 break;
531 case 755:
532 c.CureCondition<ConBleed>(value.Value);
533 break;
534 case 756:
535 c.AddCondition<ConHotspring>(value.Value * 2)?.SetPerfume();
536 break;
537 case 760:
538 if (!c.HasCondition<ConAwakening>())
539 {
540 flag = true;
541 }
542 c.AddCondition<ConAwakening>(1000 + value.Value * 20);
543 break;
544 case 761:
545 if (c.HasCondition<ConAwakening>() && !flag)
546 {
547 if (c.IsPC)
548 {
549 Msg.Say("recharge_stamina_fail");
550 }
551 }
552 else
553 {
554 c.Say("recharge_stamina", c);
555 c.stamina.Mod(c.stamina.max * (value.Value / 10 + 1) / 100 + value.Value * 2 / 3 + EClass.rnd(5));
556 }
557 break;
558 }
559 }
560 else
561 {
562 switch (value.id)
563 {
564 case 753:
565 SayTaste("food_poison");
566 c.AddCondition<ConPoison>(-value.Value * 10);
567 break;
568 case 754:
569 SayTaste("food_mind");
570 c.AddCondition<ConConfuse>(-value.Value * 10);
571 c.AddCondition<ConInsane>(-value.Value * 10);
572 c.AddCondition<ConHallucination>(-value.Value * 20);
573 break;
574 case 755:
575 c.AddCondition<ConBleed>(-value.Value * 10);
576 break;
577 case 756:
578 c.hygiene.Mod(-value.Value * 5);
579 break;
580 case 760:
581 c.RemoveCondition<ConAwakening>();
582 c.sleepiness.Mod(value.Value);
583 break;
584 case 761:
585 c.Say("recharge_stamina_negative", c);
586 c.stamina.Mod(-c.stamina.max * (-value.Value / 10 + 1) / 100 + value.Value);
587 break;
588 }
589 }
590 }
591 void SayTaste(string _id)
592 {
593 if (c.IsPC)
594 {
595 c.Say(_id);
596 }
597 }
598 }
599}
if(!match.Success)
Emo
Definition: Emo.cs:2
ID_Achievement
static void Poison(Chara tc, Chara c, int power)
Definition: ActEffect.cs:2838
static void LoveMiracle(Chara tc, Chara c, int power, EffectId idEffect=EffectId.Love, BlessedState? state=null)
Definition: ActEffect.cs:2854
void Mod(int a, bool force=false)
Definition: Card.cs:11
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6578
void SetInt(string id, int value=0)
Definition: Card.cs:2586
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:7138
Thing SetNum(int a)
Definition: Card.cs:3669
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6612
CharaGenes c_genes
Definition: Card.cs:1897
int Evalue(int ele)
Definition: Card.cs:2704
void ModExp(string alias, int a)
Definition: Card.cs:2781
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2567
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6320
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7256
static void Remove(Chara c, DNA item)
Definition: CharaGenes.cs:12
List< DNA > items
Definition: CharaGenes.cs:7
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9701
override bool IsPC
Definition: Chara.cs:630
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:10344
override bool IsPCParty
Definition: Chara.cs:633
int MaxGeneSlot
Definition: Chara.cs:1091
bool HasCondition(string alias)
Definition: Chara.cs:9866
Stats hunger
Definition: Chara.cs:1177
bool IsHuman
Definition: Chara.cs:902
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4495
override bool IsPCFaction
Definition: Chara.cs:689
void Vomit()
Definition: Chara.cs:5515
Stats SAN
Definition: Chara.cs:1193
SourceThing.Row GetFavFood()
Definition: Chara.cs:8389
void AddFoodHistory(Thing food)
Definition: Chara.cs:10609
int CountNumEaten(Thing food)
Definition: Chara.cs:10629
bool isDead
Definition: Chara.cs:393
bool IsCat
Definition: Chara.cs:1010
bool enable
Definition: CoreDebug.cs:301
Definition: DNA.cs:8
Type type
Definition: DNA.cs:29
Type
Definition: DNA.cs:10
int slot
Definition: DNA.cs:77
void Apply(Chara c)
Definition: DNA.cs:178
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static int rndHalf(int a)
Definition: EClass.cs:97
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
int id
Definition: ELEMENT.cs:257
SourceElement.Row source
Definition: ELEMENT.cs:280
int Value
Definition: ELEMENT.cs:299
bool IsTrait
Definition: ELEMENT.cs:369
bool IsMainAttribute
Definition: ELEMENT.cs:390
static void ProcNutrition(Chara c, Thing food, float effP, float validFill)
Definition: FoodEffect.cs:388
static void ProcTrait(Chara c, Card food)
Definition: FoodEffect.cs:512
static bool IsLeftoverable(Thing food)
Definition: FoodEffect.cs:7
static void ProcDrink(Chara c, Thing food)
Definition: FoodEffect.cs:364
static void Proc(Chara c, Thing food, bool consume=true)
Definition: FoodEffect.cs:16
static bool Has(string id)
Definition: LangGame.cs:99
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
int angryCats
Definition: Player.cs:138
void ModKarma(int a)
Definition: Player.cs:2610
Stats stats
Definition: Player.cs:1083
List< Chara > ListCharasInRadius(Chara cc, int dist, Func< Chara, bool > func, bool onlyVisible=true)
Definition: Point.cs:1226
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
Definition: Steam.cs:10
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:51
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:208
GameDate date
Definition: World.cs:6
bool HasField(int idEle)
Definition: Zone.cs:3065