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