Elin Decompiled Documentation EA 23.188 Stable Patch 2
Loading...
Searching...
No Matches
FoodEffect Class Reference
Inheritance diagram for FoodEffect:
EClass

Static Public Member Functions

static bool IsLeftoverable (Thing food)
 
static void Proc (Chara c, Thing food, bool consume=true)
 
static void ProcTrait (Chara c, Card t)
 
- Static Public Member Functions inherited from EClass
static int rndSeed (int a, int seed)
 
static int rnd (long a)
 
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Additional Inherited Members

- Static Public Attributes inherited from EClass
static Core core
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 4 of file FoodEffect.cs.

Member Function Documentation

◆ IsLeftoverable()

static bool FoodEffect.IsLeftoverable ( Thing  food)
inlinestatic

Definition at line 6 of file FoodEffect.cs.

7 {
8 return food.trait is TraitLunch;
9 }

Referenced by Proc(), and Thing.WriteNote().

◆ Proc()

static void FoodEffect.Proc ( Chara  c,
Thing  food,
bool  consume = true 
)
inlinestatic

Definition at line 11 of file FoodEffect.cs.

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 return;
220 }
221 break;
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 flag6 = false;
255 break;
256 }
257 }
258 }
259 }
260 ProcTrait(c, food);
261 num4 += (float)food.Evalue(70);
262 num4 += (float)(food.Evalue(72) / 2);
263 num4 += (float)(food.Evalue(73) / 2);
264 num4 += (float)(food.Evalue(75) / 2);
265 num4 += (float)(food.Evalue(76) * 3 / 2);
266 num4 += (float)food.Evalue(440);
267 num4 += (float)(food.Evalue(445) / 2);
268 num4 -= (float)food.Evalue(71);
269 num4 += (float)(num3 / 2);
270 num4 *= num5;
271 if (idTaste.IsEmpty())
272 {
273 if (num4 > 100f)
274 {
275 idTaste = "food_great";
276 }
277 else if (num4 > 70f)
278 {
279 idTaste = "food_good";
280 }
281 else if (num4 > 50f)
282 {
283 idTaste = "food_soso";
284 }
285 else if (num4 > 30f)
286 {
287 idTaste = "food_average";
288 }
289 else
290 {
291 idTaste = "food_bad";
292 }
293 if (c.IsPC)
294 {
295 c.Say(idTaste);
296 if (flag2)
297 {
298 c.Say(flag4 ? "food_human_pos" : "food_human_neg");
299 }
300 else if (flag4)
301 {
302 c.Say("food_human_whine");
303 }
304 }
305 }
306 if (LangGame.Has(idTaste + "2"))
307 {
308 c.Say(idTaste + "2", c, food);
309 }
310 if (!c.IsPCParty)
311 {
312 num3 *= 2;
313 }
314 num3 = num3 * (100 + c.Evalue(1235) * 10) / (100 + c.Evalue(1234) * 10 + c.Evalue(1236) * 15);
315 c.hunger.Mod(-num3);
316 if (flag2)
317 {
318 if (!flag4)
319 {
320 if (c.IsHuman)
321 {
322 c.AddCondition<ConInsane>(200);
323 c.SAN.Mod(15);
324 }
325 if (EClass.rnd(c.IsHuman ? 5 : 20) == 0)
326 {
327 c.SetFeat(1205, 1, msg: true);
328 flag4 = true;
329 }
330 }
331 if (flag4)
332 {
333 c.SetInt(31, EClass.world.date.GetRaw() + 10080);
334 }
335 }
336 else if (flag4 && c.GetInt(31) < EClass.world.date.GetRaw())
337 {
338 c.SetFeat(1205, 0, msg: true);
339 }
340 if (flag5 && !c.HasElement(480))
341 {
343 c.AddCondition<ConConfuse>(200);
344 }
345 if (c.HasCondition<ConAnorexia>())
346 {
347 c.Vomit();
348 }
349 if (num3 > 20 && c.HasElement(1413))
350 {
351 Thing thing = ThingGen.Create("seed");
352 if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0)
353 {
354 TraitSeed.ApplySeed(thing, (EClass.rnd(4) == 0) ? 118 : ((EClass.rnd(3) == 0) ? 119 : 90));
355 }
356 thing.SetNum(2 + EClass.rnd(3));
357 c.Talk("vomit");
358 c.Say("fairy_vomit", c, thing);
359 c.PickOrDrop(c.pos, thing);
360 }
361 food.trait.OnEat(c);
362 if (food.trait is TraitDrink)
363 {
364 food.trait.OnDrink(c);
365 }
366 if (consume)
367 {
368 num7 += 5f;
369 if (flag6 && (float)food.Evalue(10) > num7 + 10f)
370 {
371 food.elements.SetTo(10, (int)Mathf.Max((float)food.Evalue(10) - num7, 1f));
372 food.SetBool(125, enable: true);
373 }
374 else
375 {
376 food.ModNum(-1);
377 }
378 }
379 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
static void Poison(Chara tc, Chara c, int power)
Definition: ActEffect.cs:2376
static void LoveMiracle(Chara tc, Chara c, int power, bool plus=false, BlessedState? state=null)
Definition: ActEffect.cs:2392
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
ElementContainerCard elements
Definition: Card.cs:39
bool HasElement(int ele, int req=1)
Definition: Card.cs:5638
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5852
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6402
Thing SetNum(int a)
Definition: Card.cs:3393
Point pos
Definition: Card.cs:57
int Evalue(int ele)
Definition: Card.cs:2533
void ModExp(string alias, int a)
Definition: Card.cs:2610
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6499
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8819
override bool IsPC
Definition: Chara.cs:610
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9377
override bool IsPCParty
Definition: Chara.cs:613
bool HasCondition(string alias)
Definition: Chara.cs:8976
Stats hunger
Definition: Chara.cs:1124
bool IsHuman
Definition: Chara.cs:877
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4167
override bool IsPCFaction
Definition: Chara.cs:669
void Vomit()
Definition: Chara.cs:5037
Stats SAN
Definition: Chara.cs:1140
SourceThing.Row GetFavFood()
Definition: Chara.cs:7660
void ModWeight(int a, bool ignoreLimit=false)
Definition: Chara.cs:9294
void AddFoodHistory(Thing food)
Definition: Chara.cs:9622
int CountNumEaten(Thing food)
Definition: Chara.cs:9642
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:248
SourceElement.Row source
Definition: ELEMENT.cs:271
int vTempPotential
Definition: ELEMENT.cs:256
int Value
Definition: ELEMENT.cs:290
bool IsMainAttribute
Definition: ELEMENT.cs:381
static bool IsLeftoverable(Thing food)
Definition: FoodEffect.cs:6
static void ProcTrait(Chara c, Card t)
Definition: FoodEffect.cs:381
static bool Has(string id)
Definition: LangGame.cs:46
Definition: Msg.cs:5
static void SetColor()
Definition: Msg.cs:22
void ModKarma(int a)
Definition: Player.cs:2408
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:169
GameDate date
Definition: World.cs:6

References Chara.AddCondition(), Chara.AddFoodHistory(), TraitSeed.ApplySeed(), ElementContainer.Base(), Chara.CountNumEaten(), ThingGen.Create(), World.date, EClass.debug, Debug, ElementContainer.dict, Card.elements, SourceManager.elements, CoreDebug.enable, Card.Evalue(), food, ElementContainer.GetElement(), Chara.GetFavFood(), BaseCard.GetInt(), Stats.GetPhase(), Date.GetRaw(), LangGame.Has(), Chara.HasCondition(), Card.HasElement(), Chara.hunger, Element.id, if(), Chara.isDead, Chara.IsHuman, IsLeftoverable(), Element.IsMainAttribute, Chara.IsPC, Chara.IsPCFaction, Chara.IsPCParty, ActEffect.LoveMiracle(), Stats.Mod(), ElementContainer.ModExp(), Card.ModExp(), Player.ModKarma(), ElementContainer.ModPotential(), ElementContainer.ModTempPotential(), Chara.ModWeight(), EClass.pc, Chara.PickOrDrop(), EClass.player, Card.PlaySound(), ActEffect.Poison(), Card.pos, ProcTrait(), Chara.race, EClass.rnd(), EClass.rndHalf(), Chara.SAN, Card.Say(), Msg.SetColor(), Chara.SetFeat(), BaseCard.SetInt(), Card.SetNum(), Element.source, EClass.sources, Card.Talk(), Element.Value, Stats.value, Chara.Vomit(), Element.vTempPotential, and EClass.world.

Referenced by Chara.InstantEat(), and AI_Eat.Run().

◆ ProcTrait()

static void FoodEffect.ProcTrait ( Chara  c,
Card  t 
)
inlinestatic

Definition at line 381 of file FoodEffect.cs.

382 {
383 bool flag = false;
384 foreach (Element value in t.elements.dict.Values)
385 {
386 if (!value.IsTrait)
387 {
388 continue;
389 }
390 if (value.Value >= 0)
391 {
392 switch (value.id)
393 {
394 case 753:
395 c.CureCondition<ConPoison>(value.Value * 2);
396 break;
397 case 754:
398 c.AddCondition<ConPeace>(value.Value * 5);
399 break;
400 case 755:
401 c.CureCondition<ConBleed>(value.Value);
402 break;
403 case 756:
404 c.AddCondition<ConHotspring>(value.Value * 2)?.SetPerfume();
405 break;
406 case 760:
407 if (!c.HasCondition<ConAwakening>())
408 {
409 flag = true;
410 }
411 c.AddCondition<ConAwakening>(1000 + value.Value * 20);
412 break;
413 case 761:
414 if (c.HasCondition<ConAwakening>() && !flag)
415 {
416 if (c.IsPC)
417 {
418 Msg.Say("recharge_stamina_fail");
419 }
420 }
421 else
422 {
423 c.Say("recharge_stamina", c);
424 c.stamina.Mod(c.stamina.max * (value.Value / 10 + 1) / 100 + value.Value * 2 / 3 + EClass.rnd(5));
425 }
426 break;
427 }
428 }
429 else
430 {
431 switch (value.id)
432 {
433 case 753:
434 SayTaste("food_poison");
435 c.AddCondition<ConPoison>(-value.Value * 10);
436 break;
437 case 754:
438 SayTaste("food_mind");
439 c.AddCondition<ConConfuse>(-value.Value * 10);
440 c.AddCondition<ConInsane>(-value.Value * 10);
441 c.AddCondition<ConHallucination>(-value.Value * 20);
442 break;
443 case 755:
444 c.AddCondition<ConBleed>(-value.Value * 10);
445 break;
446 case 756:
447 c.hygiene.Mod(-value.Value * 5);
448 break;
449 case 760:
450 c.RemoveCondition<ConAwakening>();
451 c.sleepiness.Mod(value.Value);
452 break;
453 case 761:
454 c.Say("recharge_stamina_negative", c);
455 c.stamina.Mod(-c.stamina.max * (-value.Value / 10 + 1) / 100 + value.Value);
456 break;
457 }
458 }
459 }
460 void SayTaste(string _id)
461 {
462 if (c.IsPC)
463 {
464 c.Say(_id);
465 }
466 }
467 }
Stats sleepiness
Definition: Chara.cs:1138
Stats hygiene
Definition: Chara.cs:1134
Stats stamina
Definition: Chara.cs:1128
bool IsTrait
Definition: ELEMENT.cs:360
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
virtual int max
Definition: Stats.cs:68

References Element.id, Element.IsTrait, BaseCondition.Mod(), EClass.rnd(), Msg.Say(), and Element.Value.

Referenced by TraitItemProc.OnUse(), and Proc().


The documentation for this class was generated from the following file: