Elin Decompiled Documentation EA 23.239 Nightly Patch 1
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 Chara c2 = c;
14 if (food.id == "bloodsample")
15 {
16 food.ModNum(-1);
17 return;
18 }
19 food.CheckJustCooked();
20 bool flag = EClass._zone.IsPCFaction && c2.IsInSpot<TraitSpotDining>();
21 int num = (food.isCrafted ? ((EClass.pc.Evalue(1650) >= 3) ? 5 : 0) : 0);
22 float num2 = (float)(100 + (food.HasElement(757) ? 10 : 0) + (flag ? 10 : 0) + num + Mathf.Min(food.QualityLv * 10, 100)) / 200f;
23 if (num2 < 0.1f)
24 {
25 num2 = 0.1f;
26 }
27 int num3 = Mathf.Clamp(food.Evalue(10), 0, 10000);
28 float num4 = 25f;
29 float num5 = 1f;
30 string idTaste = "";
31 bool flag2 = food.HasElement(708);
32 bool flag3 = food.HasElement(709);
33 bool flag4 = c2.HasElement(1205);
34 bool flag5 = food.IsDecayed || flag3;
35 bool flag6 = IsLeftoverable(food);
37 if (c2.IsPCFaction && !c2.IsPC)
38 {
39 int num6 = c2.CountNumEaten(food);
40 bool flag7 = c2.GetFavFood().id == food.id;
41 if (num6 < 2 || flag7)
42 {
43 if (num6 == 1 || flag7 || EClass.rnd(4) == 0)
44 {
45 c2.Talk("foodNice");
46 }
47 }
48 else if (num6 > 3 && EClass.rnd(num6) >= 3)
49 {
50 c2.Talk("foodBored");
51 }
52 }
53 if (food.IsBlessed)
54 {
55 num2 *= 1.5f;
56 }
57 if (food.IsCursed)
58 {
59 num2 *= 0.5f;
60 }
61 if (flag4)
62 {
63 if (flag2)
64 {
65 num5 *= 2f;
66 num2 *= 1.3f;
67 }
68 else
69 {
70 num5 *= 0.5f;
71 num2 /= 2f;
72 num3 /= 2;
73 }
74 }
75 else if (flag2)
76 {
77 num5 = 0f;
78 num2 *= 0.5f;
79 }
80 if (c2.HasElement(1250))
81 {
82 if (food.HasElement(710))
83 {
84 num2 = num2 * 0.1f * (float)(food.Evalue(710) + 10);
85 }
86 else
87 {
88 num3 /= 10;
89 }
90 }
91 if (c2.HasElement(1200))
92 {
93 num2 *= 1f + (float)c2.Evalue(1200) * 0.25f;
94 }
95 if (!c2.IsPC)
96 {
97 num2 *= 3f;
98 }
99 if (flag5 && !c2.HasElement(480))
100 {
101 if (c2.IsPC)
102 {
103 if (flag3)
104 {
105 c2.Say("food_undead");
106 }
107 c2.Say("food_rot");
108 }
109 num5 = 0f;
110 num3 /= 2;
111 }
112 else
113 {
114 switch (food.source._origin)
115 {
116 case "meat":
117 if (c2.IsPC)
118 {
119 c2.Say("food_raw_meat");
120 }
121 num2 *= 0.7f;
122 num5 = 0.5f;
123 break;
124 case "fish":
125 if (c2.IsHuman)
126 {
127 if (c2.IsPC)
128 {
129 c2.Say("food_raw_fish");
130 }
131 num2 *= 0.9f;
132 num5 = 0.5f;
133 }
134 break;
135 case "dough":
136 if (c2.IsPC)
137 {
138 c2.Say("food_raw_powder");
139 }
140 num2 *= 0.9f;
141 num5 = 0.5f;
142 break;
143 }
144 }
145 float num7 = Mathf.Min(c2.hunger.value, num3);
146 if (c2.hunger.GetPhase() >= 3)
147 {
148 num7 *= 1.1f;
149 }
150 if (flag5 && !c2.HasElement(480))
151 {
152 c2.ModExp(70, -300);
153 c2.ModExp(71, -300);
154 c2.ModExp(72, -200);
155 c2.ModExp(73, -200);
156 c2.ModExp(74, -200);
157 c2.ModExp(75, 500);
158 c2.ModExp(76, -200);
159 c2.ModExp(77, -300);
160 }
161 else
162 {
163 num2 = num2 * num7 / 10f;
164 if (c2.HasCondition<ConAnorexia>())
165 {
166 num2 = 0.01f;
167 }
168 List<Element> list = food.ListValidTraits(isCraft: true, limit: false);
169 foreach (Element value in food.elements.dict.Values)
170 {
171 if (value.source.foodEffect.IsEmpty() || !list.Contains(value))
172 {
173 continue;
174 }
175 string[] foodEffect = value.source.foodEffect;
176 int id = value.id;
177 float num8 = num2 * (float)value.Value;
178 if (value.source.category == "food" && c2.IsPC)
179 {
180 bool flag8 = num8 >= 0f;
181 string text = value.source.GetText(flag8 ? "textInc" : "textDec", returnNull: true);
182 if (text != null)
183 {
184 Msg.SetColor(flag8 ? "positive" : "negative");
185 c2.Say(text);
186 }
187 }
188 switch (foodEffect[0])
189 {
190 case "god":
191 {
192 int int2 = c2.GetInt(117);
193 if (int2 < 10)
194 {
195 foreach (Element value2 in c2.elements.dict.Values)
196 {
197 if (value2.IsMainAttribute)
198 {
199 c2.elements.ModPotential(value2.id, 2);
200 }
201 }
202 }
203 c2.Say("little_eat", c2);
204 c2.PlaySound("ding_potential");
205 c2.elements.ModExp(306, -1000f);
206 c2.SetInt(117, int2 + 1);
207 flag6 = false;
208 break;
209 }
210 case "exp":
211 {
212 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
213 int a = (int)(num8 * (float)((foodEffect.Length > 2) ? foodEffect[2].ToInt() : 4)) * 2 / 3;
214 c2.ModExp(id, a);
215 break;
216 }
217 case "pot":
218 {
219 id = ((foodEffect.Length > 1) ? EClass.sources.elements.alias[foodEffect[1]].id : value.id);
220 int vTempPotential = c2.elements.GetElement(id).vTempPotential;
221 int num9 = EClass.rndHalf((int)(num8 / 5f) + 1);
222 num9 = num9 * 100 / Mathf.Max(100, vTempPotential * 2 / 3);
223 c2.elements.ModTempPotential(id, num9, 8);
224 break;
225 }
226 case "karma":
227 if (c2.IsPCParty)
228 {
230 }
231 break;
232 case "poison":
233 ActEffect.Poison(c2, EClass.pc, value.Value * 10);
234 if (!c2.isDead)
235 {
236 break;
237 }
238 goto IL_0f76;
239 case "love":
240 ActEffect.LoveMiracle(c2, EClass.pc, value.Value * 10);
241 break;
242 case "loseWeight":
243 c2.ModWeight(-EClass.rndHalf(value.Value), ignoreLimit: true);
244 break;
245 case "gainWeight":
246 c2.ModWeight(EClass.rndHalf(value.Value), ignoreLimit: true);
247 break;
248 case "little":
249 {
250 int @int = c2.GetInt(112);
251 if (@int < 30)
252 {
253 c2.Say("little_eat", c2);
254 c2.PlaySound("ding_potential");
255 int v = Mathf.Max(5 - @int / 2, 1);
256 Debug.Log("sister eaten:" + @int + "/" + v);
257 foreach (Element value3 in c2.elements.dict.Values)
258 {
259 if (value3.IsMainAttribute)
260 {
261 c2.elements.ModPotential(value3.id, v);
262 }
263 }
264 }
265 if (c2.race.id == "mutant" && c2.elements.Base(1230) < 10)
266 {
267 c2.Say("little_adam", c2);
268 c2.SetFeat(1230, c2.elements.Base(1230) + 1);
269 }
270 c2.SetInt(112, @int + 1);
271 break;
272 }
273 }
274 }
275 }
276 ProcTrait(c2, food);
277 num4 += (float)food.Evalue(70);
278 num4 += (float)(food.Evalue(72) / 2);
279 num4 += (float)(food.Evalue(73) / 2);
280 num4 += (float)(food.Evalue(75) / 2);
281 num4 += (float)(food.Evalue(76) * 3 / 2);
282 num4 += (float)food.Evalue(440);
283 num4 += (float)(food.Evalue(445) / 2);
284 num4 -= (float)food.Evalue(71);
285 num4 += (float)(num3 / 2);
286 num4 *= num5;
287 if (idTaste.IsEmpty())
288 {
289 if (num4 > 100f)
290 {
291 idTaste = "food_great";
292 }
293 else if (num4 > 70f)
294 {
295 idTaste = "food_good";
296 }
297 else if (num4 > 50f)
298 {
299 idTaste = "food_soso";
300 }
301 else if (num4 > 30f)
302 {
303 idTaste = "food_average";
304 }
305 else
306 {
307 idTaste = "food_bad";
308 }
309 if (c2.IsPC)
310 {
311 c2.Say(idTaste);
312 if (flag2)
313 {
314 c2.Say(flag4 ? "food_human_pos" : "food_human_neg");
315 }
316 else if (flag4)
317 {
318 c2.Say("food_human_whine");
319 }
320 }
321 }
322 if (LangGame.Has(idTaste + "2"))
323 {
324 c2.Say(idTaste + "2", c2, food);
325 }
326 if (!c2.IsPCParty)
327 {
328 num3 *= 2;
329 }
330 num3 = num3 * (100 + c2.Evalue(1235) * 10) / (100 + c2.Evalue(1234) * 10 + c2.Evalue(1236) * 15);
331 c2.hunger.Mod(-num3);
332 if (flag2)
333 {
334 if (!flag4)
335 {
336 if (c2.IsHuman)
337 {
338 c2.AddCondition<ConInsane>(200);
339 c2.SAN.Mod(15);
340 }
341 if (EClass.rnd(c2.IsHuman ? 5 : 20) == 0)
342 {
343 c2.SetFeat(1205, 1, msg: true);
344 flag4 = true;
345 }
346 }
347 if (flag4)
348 {
349 c2.SetInt(31, EClass.world.date.GetRaw() + 10080);
350 }
351 }
352 else if (flag4 && c2.GetInt(31) < EClass.world.date.GetRaw())
353 {
354 c2.SetFeat(1205, 0, msg: true);
355 }
356 if (flag5 && !c2.HasElement(480))
357 {
359 c2.AddCondition<ConConfuse>(200);
360 }
361 if (c2.HasCondition<ConAnorexia>())
362 {
363 c2.Vomit();
364 }
365 if (num3 > 20 && c2.HasElement(1413))
366 {
367 Thing thing = ThingGen.Create("seed");
368 if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0)
369 {
370 TraitSeed.ApplySeed(thing, (EClass.rnd(4) == 0) ? 118 : ((EClass.rnd(3) == 0) ? 119 : 90));
371 }
372 thing.SetNum(2 + EClass.rnd(3));
373 c2.Talk("vomit");
374 c2.Say("fairy_vomit", c2, thing);
375 c2.PickOrDrop(c2.pos, thing);
376 }
377 food.trait.OnEat(c2);
378 if (food.trait is TraitDrink)
379 {
380 food.trait.OnDrink(c2);
381 }
382 goto IL_0f76;
383 IL_0f76:
384 if (consume)
385 {
386 num7 += 5f;
387 if (flag6 && (float)food.Evalue(10) > num7 + 10f)
388 {
389 food.elements.SetTo(10, (int)Mathf.Max((float)food.Evalue(10) - num7, 1f));
390 food.SetBool(125, enable: true);
391 if (food.HasElement(1229))
392 {
393 food.elements.Remove(1229);
394 }
395 }
396 else
397 {
398 food.ModNum(-1);
399 }
400 }
401 if (c2.IsCat || !(food.trait is TraitFoodChuryu))
402 {
403 return;
404 }
405 foreach (Chara item in c2.pos.ListCharasInRadius(c2, 5, (Chara c) => c.IsCat))
406 {
407 item.Say("angry", item);
408 item.ShowEmo(Emo.angry);
409 item.PlaySound("Animal/Cat/cat_angry");
410 if (c2.IsPC)
411 {
413 }
414 }
415 }
Emo
Definition: Emo.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
static void Poison(Chara tc, Chara c, int power)
Definition: ActEffect.cs:2641
static void LoveMiracle(Chara tc, Chara c, int power, EffectId idEffect=EffectId.Love, BlessedState? state=null)
Definition: ActEffect.cs:2657
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:5897
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6129
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6684
Thing SetNum(int a)
Definition: Card.cs:3492
Point pos
Definition: Card.cs:59
int Evalue(int ele)
Definition: Card.cs:2571
void ModExp(string alias, int a)
Definition: Card.cs:2648
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6781
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9146
override bool IsPC
Definition: Chara.cs:612
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9771
override bool IsPCParty
Definition: Chara.cs:615
bool HasCondition(string alias)
Definition: Chara.cs:9303
Stats hunger
Definition: Chara.cs:1142
bool IsHuman
Definition: Chara.cs:879
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4243
override bool IsPCFaction
Definition: Chara.cs:671
void Vomit()
Definition: Chara.cs:5217
Stats SAN
Definition: Chara.cs:1158
SourceThing.Row GetFavFood()
Definition: Chara.cs:7932
void ModWeight(int a, bool ignoreLimit=false)
Definition: Chara.cs:9684
void AddFoodHistory(Thing food)
Definition: Chara.cs:10037
int CountNumEaten(Thing food)
Definition: Chara.cs:10057
bool isDead
Definition: Chara.cs:389
bool IsCat
Definition: Chara.cs:987
SourceRace.Row race
Definition: Chara.cs:464
bool enable
Definition: CoreDebug.cs:286
int GetRaw(int offsetHours=0)
Definition: Date.cs:326
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:417
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:2511
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
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.IsCat, Chara.isDead, Chara.IsHuman, IsLeftoverable(), Element.IsMainAttribute, Chara.IsPC, Chara.IsPCFaction, Chara.IsPCParty, item, 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 AI_Fuck.Finish(), Chara.InstantEat(), and AI_Eat.Run().

◆ ProcTrait()

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

Definition at line 417 of file FoodEffect.cs.

418 {
419 bool flag = false;
420 foreach (Element value in t.elements.dict.Values)
421 {
422 if (!value.IsTrait)
423 {
424 continue;
425 }
426 if (value.Value >= 0)
427 {
428 switch (value.id)
429 {
430 case 753:
431 c.CureCondition<ConPoison>(value.Value * 2);
432 break;
433 case 754:
434 c.AddCondition<ConPeace>(value.Value * 5);
435 break;
436 case 755:
437 c.CureCondition<ConBleed>(value.Value);
438 break;
439 case 756:
440 c.AddCondition<ConHotspring>(value.Value * 2)?.SetPerfume();
441 break;
442 case 760:
443 if (!c.HasCondition<ConAwakening>())
444 {
445 flag = true;
446 }
447 c.AddCondition<ConAwakening>(1000 + value.Value * 20);
448 break;
449 case 761:
450 if (c.HasCondition<ConAwakening>() && !flag)
451 {
452 if (c.IsPC)
453 {
454 Msg.Say("recharge_stamina_fail");
455 }
456 }
457 else
458 {
459 c.Say("recharge_stamina", c);
460 c.stamina.Mod(c.stamina.max * (value.Value / 10 + 1) / 100 + value.Value * 2 / 3 + EClass.rnd(5));
461 }
462 break;
463 }
464 }
465 else
466 {
467 switch (value.id)
468 {
469 case 753:
470 SayTaste("food_poison");
471 c.AddCondition<ConPoison>(-value.Value * 10);
472 break;
473 case 754:
474 SayTaste("food_mind");
475 c.AddCondition<ConConfuse>(-value.Value * 10);
476 c.AddCondition<ConInsane>(-value.Value * 10);
477 c.AddCondition<ConHallucination>(-value.Value * 20);
478 break;
479 case 755:
480 c.AddCondition<ConBleed>(-value.Value * 10);
481 break;
482 case 756:
483 c.hygiene.Mod(-value.Value * 5);
484 break;
485 case 760:
486 c.RemoveCondition<ConAwakening>();
487 c.sleepiness.Mod(value.Value);
488 break;
489 case 761:
490 c.Say("recharge_stamina_negative", c);
491 c.stamina.Mod(-c.stamina.max * (-value.Value / 10 + 1) / 100 + value.Value);
492 break;
493 }
494 }
495 }
496 void SayTaste(string _id)
497 {
498 if (c.IsPC)
499 {
500 c.Say(_id);
501 }
502 }
503 }
Stats sleepiness
Definition: Chara.cs:1156
Stats hygiene
Definition: Chara.cs:1152
Stats stamina
Definition: Chara.cs:1146
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 TraitLumiestCrimAle.OnDrink(), TraitItemProc.OnUse(), and Proc().


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