Elin Decompiled Documentation EA 23.221 Nightly
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 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 }
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
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
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8986
override bool IsPC
Definition: Chara.cs:610
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9586
override bool IsPCParty
Definition: Chara.cs:613
bool HasCondition(string alias)
Definition: Chara.cs:9143
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:5151
Stats SAN
Definition: Chara.cs:1152
SourceThing.Row GetFavFood()
Definition: Chara.cs:7822
void ModWeight(int a, bool ignoreLimit=false)
Definition: Chara.cs:9503
void AddFoodHistory(Thing food)
Definition: Chara.cs:9852
int CountNumEaten(Thing food)
Definition: Chara.cs:9872
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 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 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: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

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 387 of file FoodEffect.cs.

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 }
Stats sleepiness
Definition: Chara.cs:1150
Stats hygiene
Definition: Chara.cs:1146
Stats stamina
Definition: Chara.cs:1140
bool IsTrait
Definition: ELEMENT.cs:362
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: