Elin Decompiled Documentation EA 23.336 Nightly
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 if (num3 < 1)
217 {
218 num3 = 1;
219 }
220 c.hunger.Mod(-num3);
221 if (flag2)
222 {
223 if (!flag4)
224 {
225 if (c.IsHuman)
226 {
227 c.AddCondition<ConInsane>(200);
228 c.SAN.Mod(15);
229 }
230 if (EClass.rnd(c.IsHuman ? 5 : 20) == 0)
231 {
232 c.SetFeat(1205, 1, msg: true);
233 flag4 = true;
234 }
235 }
236 if (flag4)
237 {
238 c.SetInt(31, EClass.world.date.GetRaw() + 10080);
239 }
240 }
241 else if (flag4 && c.GetInt(31) < EClass.world.date.GetRaw())
242 {
243 c.SetFeat(1205, 0, msg: true);
244 }
245 if (flag5 && !c.HasElement(480))
246 {
248 c.AddCondition<ConConfuse>(200);
249 }
250 if (c.HasCondition<ConAnorexia>())
251 {
252 c.Vomit();
253 }
254 if (num3 > 20 && c.HasElement(1413))
255 {
256 Thing thing = ThingGen.Create("seed");
257 if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0)
258 {
259 TraitSeed.ApplySeed(thing, (EClass.rnd(4) == 0) ? 118 : ((EClass.rnd(3) == 0) ? 119 : 90));
260 }
261 thing.SetNum(2 + EClass.rnd(3));
262 c.Talk("vomit");
263 c.Say("fairy_vomit", c, thing);
264 c.PickOrDrop(c.pos, thing);
265 }
266 food.trait.OnEat(c);
267 }
268 }
269 if (consume)
270 {
271 num7 += 5f;
272 if (flag6 && (float)food.Evalue(10) > num7 + 10f)
273 {
274 food.elements.SetTo(10, (int)Mathf.Max((float)food.Evalue(10) - num7, 1f));
275 food.SetBool(125, enable: true);
276 if (food.HasElement(1229))
277 {
278 food.elements.Remove(1229);
279 }
280 }
281 else
282 {
283 food.ModNum(-1);
284 }
285 }
286 if (c.isDead)
287 {
288 return;
289 }
290 if (!c.IsCat && food.trait is TraitFoodChuryu)
291 {
292 int num8 = 0;
293 foreach (Chara item in c.pos.ListCharasInRadius(c, 5, (Chara c) => c.IsCat))
294 {
295 item.Say("angry", item);
296 item.ShowEmo(Emo.angry);
297 item.PlaySound("Animal/Cat/cat_angry");
298 if (c.IsPC)
299 {
301 }
302 num8++;
303 }
304 EClass.player.stats.angryCats += num8;
305 Debug.Log(num8 + "/" + EClass.player.stats.angryCats);
306 if (num8 >= 10)
307 {
309 }
310 }
311 if (c.IsPC && EClass._zone is Zone_Lothria)
312 {
313 switch (food.id)
314 {
315 case "681":
316 case "pie_meat":
317 case "pie_fish":
319 break;
320 }
321 }
322 if (!(food.trait is TraitGene) || !c.IsSlimeEvolvable)
323 {
324 return;
325 }
326 DNA c_DNA = food.c_DNA;
327 int slot = c_DNA.slot;
328 CharaGenes genes = c.c_genes;
329 int excess = c.CurrentGeneSlot + slot - c.MaxGeneSlot;
330 switch (c_DNA.type)
331 {
332 case DNA.Type.Inferior:
333 if (genes != null)
334 {
335 RemoveDNA(fromOldest: false);
336 }
337 return;
338 case DNA.Type.Brain:
339 if (genes != null)
340 {
341 genes.items.Shuffle();
342 Msg.Say("reconstruct", c);
343 c.Say("food_mind", c);
345 }
346 return;
347 }
348 if (excess > 0)
349 {
350 while (excess > 0 && genes != null && genes.items.Count != 0)
351 {
352 RemoveDNA(fromOldest: true);
353 }
354 }
355 c_DNA.Apply(c);
356 c.Say("little_eat", c);
357 c.PlaySound("ding_potential");
358 SE.Play("mutation");
359 c.PlayEffect("identify");
360 void RemoveDNA(bool fromOldest)
361 {
362 DNA dNA = (fromOldest ? genes.items[0] : genes.items.Last());
363 CharaGenes.Remove(c, dNA);
364 excess -= dNA.slot;
365 }
366 }
367
368 public static void ProcDrink(Chara c, Thing food)
369 {
370 int num = Mathf.Max(1, food.Evalue(10));
371 float num2 = (float)(100 + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
372 if (num2 < 0.1f)
373 {
374 num2 = 0.1f;
375 }
376 if (c.hunger.GetPhase() <= 0)
377 {
378 num = 0;
379 }
380 c.hunger.Mod(-num);
381 ProcNutrition(c, food, num2, num);
382 if (!c.isDead)
383 {
384 ProcTrait(c, food);
385 }
386 if (!c.isDead)
387 {
388 food.trait.OnDrink(c);
389 }
390 }
391
392 public static void ProcNutrition(Chara c, Thing food, float effP, float validFill)
393 {
394 bool flag = food.HasElement(709);
395 if ((food.IsDecayed || flag) && !c.HasElement(480))
396 {
397 c.ModExp(70, -300);
398 c.ModExp(71, -300);
399 c.ModExp(72, -200);
400 c.ModExp(73, -200);
401 c.ModExp(74, -200);
402 c.ModExp(75, 500);
403 c.ModExp(76, -200);
404 c.ModExp(77, -300);
405 return;
406 }
407 effP = effP * validFill / 10f;
408 if (c.HasCondition<ConAnorexia>())
409 {
410 effP = 0.01f;
411 }
412 List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
413 foreach (Element value in food.elements.dict.Values)
414 {
415 if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
416 {
417 continue;
418 }
419 string[] foodEffect = value.source.foodEffect;
420 int id = value.id;
421 float v = effP * (float)Mathf.Min(value.Value, 10000);
422 if (value.source.category == "food" && c.IsPC)
423 {
424 bool flag2 = v >= 0f;
425 string text = value.source.GetText(flag2 ? "textInc" : "textDec", returnNull: true);
426 if (text != null)
427 {
428 Msg.SetColor(flag2 ? "positive" : "negative");
429 c.Say(text);
430 }
431 }
432 switch (foodEffect[0])
433 {
434 case "god":
435 {
436 int int2 = c.GetInt(117);
437 if (int2 < 10)
438 {
439 foreach (Element value2 in c.elements.dict.Values)
440 {
441 if (value2.IsMainAttribute)
442 {
443 c.elements.ModPotential(value2.id, 2);
444 }
445 }
446 }
447 c.Say("little_eat", c);
448 c.PlaySound("ding_potential");
449 c.elements.ModExp(306, -1000f);
450 c.SetInt(117, int2 + 1);
451 break;
452 }
453 case "exp":
454 {
455 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
456 int a = (int)(v * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
457 c.ModExp(id, a);
458 break;
459 }
460 case "pot":
461 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
462 AddPotential(id);
463 break;
464 case "catechin":
465 AddPotential(71);
466 AddPotential(75);
467 c.ModWeight(-EClass.rndHalf(value.Value / 5));
468 break;
469 case "karma":
470 if (c.IsPCParty)
471 {
473 }
474 break;
475 case "poison":
476 ActEffect.Poison(c, EClass.pc, value.Value * 10);
477 break;
478 case "love":
479 ActEffect.LoveMiracle(c, EClass.pc, value.Value * 10);
480 break;
481 case "loseWeight":
482 c.ModWeight(-EClass.rndHalf(value.Value), ignoreLimit: true);
483 break;
484 case "gainWeight":
485 c.ModWeight(EClass.rndHalf(value.Value), ignoreLimit: true);
486 break;
487 case "little":
488 {
489 int @int = c.GetInt(112);
490 if (@int < 30)
491 {
492 c.Say("little_eat", c);
493 c.PlaySound("ding_potential");
494 int v2 = Mathf.Max(5 - @int / 2, 1);
495 Debug.Log("sister eaten:" + @int + "/" + v2);
496 foreach (Element value3 in c.elements.dict.Values)
497 {
498 if (value3.IsMainAttribute)
499 {
500 c.elements.ModPotential(value3.id, v2);
501 }
502 }
503 }
504 if (c.race.id == "mutant" && c.elements.Base(1230) < 10)
505 {
506 c.Say("little_adam", c);
507 c.SetFeat(1230, c.elements.Base(1230) + 1);
508 }
509 c.SetInt(112, @int + 1);
510 break;
511 }
512 }
513 void AddPotential(int idEle)
514 {
515 int vTempPotential = c.elements.GetElement(idEle).vTempPotential;
516 int num = EClass.rndHalf((int)(v / 5f) + 1);
517 num = num * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
518 c.elements.ModTempPotential(idEle, num, 8);
519 }
520 }
521 }
522
523 public static void ProcTrait(Chara c, Card food)
524 {
525 bool flag = false;
526 foreach (Element value in food.elements.dict.Values)
527 {
528 if (!value.IsTrait)
529 {
530 continue;
531 }
532 if (value.Value >= 0)
533 {
534 switch (value.id)
535 {
536 case 753:
537 c.CureCondition<ConPoison>(value.Value * 2);
538 break;
539 case 754:
540 c.AddCondition<ConPeace>(value.Value * 5);
541 break;
542 case 755:
543 c.CureCondition<ConBleed>(value.Value);
544 break;
545 case 756:
546 c.AddCondition<ConHotspring>(value.Value * 2)?.SetPerfume();
547 break;
548 case 760:
549 if (!c.HasCondition<ConAwakening>())
550 {
551 flag = true;
552 }
553 c.AddCondition<ConAwakening>(1000 + value.Value * 20);
554 break;
555 case 761:
556 if (c.HasCondition<ConAwakening>() && !flag)
557 {
558 if (c.IsPC)
559 {
560 Msg.Say("recharge_stamina_fail");
561 }
562 }
563 else
564 {
565 c.Say("recharge_stamina", c);
566 c.stamina.Mod(c.stamina.max * (value.Value / 10 + 1) / 100 + value.Value * 2 / 3 + EClass.rnd(5));
567 }
568 break;
569 }
570 }
571 else
572 {
573 switch (value.id)
574 {
575 case 753:
576 SayTaste("food_poison");
577 c.AddCondition<ConPoison>(-value.Value * 10);
578 break;
579 case 754:
580 SayTaste("food_mind");
581 c.AddCondition<ConConfuse>(-value.Value * 10);
582 c.AddCondition<ConInsane>(-value.Value * 10);
583 c.AddCondition<ConHallucination>(-value.Value * 20);
584 break;
585 case 755:
586 c.AddCondition<ConBleed>(-value.Value * 10);
587 break;
588 case 756:
589 c.hygiene.Mod(-value.Value * 5);
590 break;
591 case 760:
592 c.RemoveCondition<ConAwakening>();
593 c.sleepiness.Mod(value.Value);
594 break;
595 case 761:
596 c.Say("recharge_stamina_negative", c);
597 c.stamina.Mod(-c.stamina.max * (-value.Value / 10 + 1) / 100 + value.Value);
598 break;
599 }
600 }
601 }
602 void SayTaste(string _id)
603 {
604 if (c.IsPC)
605 {
606 c.Say(_id);
607 }
608 }
609 }
610}
Emo
Definition: Emo.cs:2
ID_Achievement
static void Poison(Chara tc, Chara c, int power)
Definition: ActEffect.cs:2961
static void LoveMiracle(Chara tc, Chara c, int power, EffectId idEffect=EffectId.Love, BlessedState? state=null)
Definition: ActEffect.cs:2977
void Mod(int a, bool force=false)
Definition: Card.cs:11
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6633
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:7193
Thing SetNum(int a)
Definition: Card.cs:3673
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6667
CharaGenes c_genes
Definition: Card.cs:1897
int Evalue(int ele)
Definition: Card.cs:2704
bool IsSlimeEvolvable
Definition: Card.cs:2312
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:6371
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7311
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:9812
override bool IsPC
Definition: Chara.cs:630
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:10474
override bool IsPCParty
Definition: Chara.cs:633
int MaxGeneSlot
Definition: Chara.cs:1115
bool HasCondition(string alias)
Definition: Chara.cs:9984
Stats hunger
Definition: Chara.cs:1201
bool IsHuman
Definition: Chara.cs:926
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4545
override bool IsPCFaction
Definition: Chara.cs:689
void Vomit()
Definition: Chara.cs:5586
Stats SAN
Definition: Chara.cs:1217
SourceThing.Row GetFavFood()
Definition: Chara.cs:8481
void AddFoodHistory(Thing food)
Definition: Chara.cs:10739
int CountNumEaten(Thing food)
Definition: Chara.cs:10759
bool isDead
Definition: Chara.cs:393
bool IsCat
Definition: Chara.cs:1034
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:259
SourceElement.Row source
Definition: ELEMENT.cs:282
int Value
Definition: ELEMENT.cs:301
bool IsTrait
Definition: ELEMENT.cs:371
bool IsMainAttribute
Definition: ELEMENT.cs:392
static void ProcNutrition(Chara c, Thing food, float effP, float validFill)
Definition: FoodEffect.cs:392
static void ProcTrait(Chara c, Card food)
Definition: FoodEffect.cs:523
static bool IsLeftoverable(Thing food)
Definition: FoodEffect.cs:7
static void ProcDrink(Chara c, Thing food)
Definition: FoodEffect.cs:368
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:135
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:12
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:53
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:3090