Elin Decompiled Documentation EA 23.339.0 Nightly
Loading...
Searching...
No Matches
Religion.cs
Go to the documentation of this file.
1using System;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class Religion : EClass
6{
7 public enum ConvertType
8 {
11 }
12
13 public enum PunishType
14 {
15 Wrath,
18 }
19
20 [JsonProperty]
21 public int relation;
22
23 [JsonProperty]
24 public int giftRank;
25
26 [JsonProperty]
27 public int mood;
28
29 public static Religion recentWrath;
30
32
33 public virtual string id => "";
34
35 public virtual bool IsAvailable => false;
36
37 public virtual string Name => source.GetName();
38
40 {
41 get
42 {
44 if (row == null)
45 {
46 SourceReligion.Row obj = EClass.sources.religions.map.TryGetValue(id) ?? EClass.sources.religions.map["eyth"];
47 SourceReligion.Row row2 = obj;
48 _source = obj;
49 row = row2;
50 }
51 return row;
52 }
53 }
54
55 public virtual string NameShort => source.GetTextArray("name2")[1];
56
57 public virtual string NameDomain => source.GetTextArray("name2")[0];
58
59 public virtual string TextType => ("sub_" + source.type).lang();
60
61 public virtual string TextGodGender => source.GetText("textType");
62
63 public virtual string TextMood => GetTextTemper();
64
65 public bool IsEyth => id == "eyth";
66
67 public bool IsEhekatl => id == "luck";
68
69 public bool IsOpatos => id == "earth";
70
71 public virtual bool IsMinorGod => false;
72
73 public virtual bool CanJoin => true;
74
75 public virtual SourceElement.Row GetFeat(int i)
76 {
77 return EClass.sources.elements.alias["featGod_" + id + i];
78 }
79
80 public virtual void Init()
81 {
82 relation = source.relation;
83 }
84
85 public virtual void OnLoad()
86 {
87 }
88
89 public virtual void OnAdvanceDay()
90 {
91 }
92
93 public virtual Sprite GetSprite()
94 {
95 return ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/" + source.id) ?? ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/eyth");
96 }
97
98 public virtual void SetTextRelation(UIText text)
99 {
100 if (relation > 100)
101 {
102 text.SetText("reFriend".lang(), FontColor.Good);
103 }
104 else if (relation < -100)
105 {
106 text.SetText("reEnemy".lang(), FontColor.Bad);
107 }
108 else
109 {
110 text.SetText("reNone".lang(), FontColor.Passive);
111 }
112 }
113
114 public virtual string GetTextBenefit()
115 {
116 string text = "<color=green>";
117 for (int i = 0; i < source.elements.Length; i += 2)
118 {
119 if (i != 0)
120 {
121 text = text + Lang.words.comma + Lang.space;
122 }
123 text += EClass.sources.elements.map[source.elements[i]].GetName();
124 }
125 text += "</color>";
126 return source.GetText("textBenefit") + Environment.NewLine + Environment.NewLine + (IsEyth ? "" : "textBenefit".lang(text));
127 }
128
129 public virtual string GetTextTemper(int _temper = -99999)
130 {
131 if (IsEyth)
132 {
133 return "-";
134 }
135 if (_temper == -99999)
136 {
137 _temper = mood;
138 }
139 string[] list = Lang.GetList("temper");
140 if (_temper <= -15)
141 {
142 if (_temper > -85)
143 {
144 if (_temper <= -45)
145 {
146 return list[1].ToTitleCase().TagColor(FontColor.Bad);
147 }
148 return list[2].ToTitleCase();
149 }
150 return list[0].ToTitleCase().TagColor(FontColor.Bad);
151 }
152 if (_temper < 45)
153 {
154 if (_temper < 15)
155 {
156 return list[3].ToTitleCase();
157 }
158 return list[4].ToTitleCase();
159 }
160 if (_temper < 85)
161 {
162 return list[5].ToTitleCase().TagColor(FontColor.Great);
163 }
164 return list[6].ToTitleCase().TagColor(FontColor.Good);
165 }
166
167 public virtual void Revelation(string idTalk, Card c, int chance = 100)
168 {
169 if (!IsEyth && EClass.rnd(100) <= chance)
170 {
171 Talk(idTalk, c);
172 }
173 }
174
175 public virtual void Talk(string idTalk, Card c = null, Card agent = null)
176 {
178 Msg.Say("<i>" + GetGodTalk(idTalk) + " </i>", c ?? EClass.pc);
179 }
180
181 public virtual string GetGodTalk(string idTalk)
182 {
183 return MOD.listGodTalk.GetTalk(id, idTalk);
184 }
185
186 public virtual int GetOfferingMtp(Thing t)
187 {
188 return 0;
189 }
190
191 public virtual int GetOfferingValue(Thing t, int num = -1)
192 {
193 t.CheckJustCooked();
194 if (num == -1)
195 {
196 num = t.Num;
197 }
198 long v = 0L;
199 if (t.source._origin == "meat")
200 {
201 v = Mathf.Clamp(t.SelfWeight / 10, 1, 1000);
202 if (t.refCard == null)
203 {
204 v /= 10L;
205 }
206 }
207 else if (GetOfferingMtp(t) > 0)
208 {
209 SetValue(t.category, GetOfferingMtp(t));
210 }
211 else
212 {
213 string[] cat_offer = source.cat_offer;
214 foreach (string key in cat_offer)
215 {
216 if (t.category.IsChildOf(key))
217 {
218 SetValue(EClass.sources.categories.map[key], 1);
219 break;
220 }
221 }
222 }
223 if (v == 0L)
224 {
225 return 0;
226 }
227 if (t.IsDecayed)
228 {
229 v /= 10L;
230 }
231 v = v * (100 + Mathf.Min(t.LV * 2, 100) + (t.HasElement(757) ? 50 : 0)) / 100;
232 v = (int)Mathf.Clamp(Mathf.Max(v, 1f) * (float)num, 1f, 214748370f);
233 return (int)v;
234 void SetValue(SourceCategory.Row cat, int mtp)
235 {
236 v = Mathf.Clamp(t.SelfWeight / 10, 50, 1000);
237 v = v * cat.offer * mtp / 100;
238 }
239 }
240
241 public virtual int GetGiftRank(Chara chara = null)
242 {
243 if (IsEyth || source.rewards.Length == 0)
244 {
245 return -1;
246 }
247 int num = (chara ?? EClass.pc).Evalue(85);
248 if (giftRank == 0 && (num >= 15 || EClass.debug.enable))
249 {
250 return 1;
251 }
252 if (source.rewards.Length >= 2 && giftRank == 1 && (num >= 30 || EClass.debug.enable))
253 {
254 return 2;
255 }
256 return -1;
257 }
258
259 public virtual bool TryGetGift(Chara chara = null)
260 {
261 if (chara == null)
262 {
263 chara = EClass.pc;
264 }
265 int num = GetGiftRank(chara);
266 if (num == -1)
267 {
268 return false;
269 }
270 Point point = chara.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? chara.pos;
271 switch (num)
272 {
273 case 1:
274 {
275 Talk("pet");
276 Chara chara2 = CharaGen.Create(source.rewards[0]);
277 EClass._zone.AddCard(chara2, point);
278 chara2.MakeAlly();
279 chara2.PlayEffect("aura_heaven");
280 giftRank = 1;
281 return true;
282 }
283 case 2:
284 {
285 Talk("gift");
286 string[] array = source.rewards[1].Split('|');
287 string[] array2 = array;
288 foreach (string text in array2)
289 {
290 EClass.game.religions.Reforge(text, point, text == array[0]);
291 }
292 giftRank = 2;
293 return true;
294 }
295 default:
296 return false;
297 }
298 }
299
300 public virtual void OnReforge(Thing t)
301 {
302 t.c_idDeity = id;
303 if (IsIgnoreReforge(t))
304 {
305 return;
306 }
307 foreach (Element value in t.elements.dict.Values)
308 {
309 int num = value.id;
310 if ((uint)(num - 64) > 3u && num != 92 && IsFaithElement(value))
311 {
312 value.vExp = -1;
313 }
314 }
315 }
316
317 public virtual bool IsIgnoreReforge(Thing t)
318 {
319 return false;
320 }
321
322 public virtual bool IsValidArtifact(string id)
323 {
324 return false;
325 }
326
327 public virtual bool IsFaithElement(Element e)
328 {
329 return false;
330 }
331
332 public virtual string[] GetValidArtifacts()
333 {
334 return Array.Empty<string>();
335 }
336
337 public virtual void OnBecomeBranchFaith()
338 {
339 }
340
341 public virtual void JoinFaith(Chara c, ConvertType type = ConvertType.Default)
342 {
343 if (!c.IsPC)
344 {
345 c.faith = this;
347 EClass.Sound.Play("worship");
348 Msg.Say("changeFaith", c, Name);
349 return;
350 }
351 if (c.faith != this)
352 {
353 c.faith.LeaveFaith(c, this, type);
354 }
355 if (type != ConvertType.Campaign)
356 {
357 c.c_daysWithGod = 0;
358 }
359 Msg.Say("worship", Name);
360 Talk("worship", c);
361 EClass.Sound.Play("worship");
362 c.PlayEffect("aura_heaven");
363 c.faith = this;
364 OnJoinFaith();
365 if (IsEyth)
366 {
367 mood = 0;
368 }
369 else
370 {
371 mood = 50;
372 }
374 if (!c.HasElement(306))
375 {
376 c.elements.Learn(306);
377 }
378 if (!c.IsPC)
379 {
380 return;
381 }
383 if (EClass._zone.lv == 0)
384 {
385 if (EClass._zone is Zone_Mifu)
386 {
387 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.Trickery;
389 }
390 if (EClass._zone is Zone_Nefu)
391 {
392 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.MoonShadow;
394 }
395 if (EClass._zone is Zone_Aquli)
396 {
397 EClass._map.config.fixedCondition = ((EClass.pc.faith == EClass.game.religions.Strife) ? Weather.Condition.Ether : Weather.Condition.None);
399 }
400 }
402 if (this is ReligionHealing)
403 {
404 Steam.GetAchievement(ID_Achievement.FAITH_HEALING);
405 }
406 }
407
408 public virtual void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
409 {
410 bool flag = (newFaith == EClass.game.religions.Trickery && this == EClass.game.religions.MoonShadow) || (newFaith == EClass.game.religions.MoonShadow && this == EClass.game.religions.Trickery);
411 if (c.IsPC)
412 {
413 Msg.Say("worship2");
414 if (!flag && type != ConvertType.Campaign)
415 {
416 Punish(c);
417 }
418 }
419 if (flag)
420 {
421 Talk("regards");
422 c.elements.SetBase(85, c.Evalue(85) / 2);
423 }
424 else
425 {
426 c.elements.SetBase(85, 0);
427 }
429 if (c.IsPC)
430 {
432 }
433 OnLeaveFaith();
435 }
436
437 public virtual void Punish(Chara c)
438 {
439 DoPunish(c, PunishType.Wrath);
440 }
441
442 public virtual void PunishTakeOver(Chara c)
443 {
444 DoPunish(c, PunishType.Takeover);
445 }
446
447 public virtual void PunishPerverseWretch(Chara c)
448 {
449 DoPunish(c, PunishType.Pervert);
450 }
451
452 public void DoPunish(Chara c, PunishType type)
453 {
454 if (c.mimicry != null)
455 {
456 c.mimicry.Kill();
457 }
458 Talk((type == PunishType.Takeover) ? "takeoverFail" : "wrath");
459 if ((type == PunishType.Wrath || type == PunishType.Takeover) && c.Evalue(1228) > 0)
460 {
462 return;
463 }
464 if (type == PunishType.Wrath)
465 {
466 c.hp = 1;
467 if (c.mana.value > 0)
468 {
469 c.mana.value = 1;
470 }
471 if (c.stamina.value > 0)
472 {
473 c.stamina.value = 1;
474 }
475 }
476 else
477 {
478 c.hp /= 2;
479 if (c.mana.value > 0)
480 {
481 c.mana.value = c.mana.value / 2;
482 }
483 if (c.stamina.value > 0)
484 {
485 c.stamina.value = c.stamina.value / 2;
486 }
487 }
488 if (c.HasCondition<ConWrath>())
489 {
490 recentWrath = this;
491 c.DamageHP(99999999L, AttackSource.Wrath);
492 recentWrath = null;
493 return;
494 }
495 Thing thing = ThingGen.Create("punish_ball");
496 int p = 100;
497 switch (type)
498 {
499 case PunishType.Wrath:
500 {
501 p = 2000 + (c.IsPC ? (EClass.pc.c_daysWithGod * 20) : 0);
502 if (type != PunishType.Wrath)
503 {
504 break;
505 }
506 int num = 0;
508 {
509 if (item.giftRank > 0)
510 {
511 num++;
512 }
513 }
514 if (num >= 4)
515 {
516 thing.idSkin = 1;
517 }
518 break;
519 }
520 case PunishType.Takeover:
521 case PunishType.Pervert:
522 p = 200;
523 break;
524 }
525 thing.ChangeWeight(c.WeightLimit / 4 + 1000);
526 c.AddThing(thing);
528 }
529
530 public virtual void OnJoinFaith()
531 {
532 }
533
534 public virtual void OnLeaveFaith()
535 {
536 }
537
538 public virtual void OnChangeHour()
539 {
540 if (IsEyth)
541 {
542 mood = 0;
543 }
544 else
545 {
546 mood = EClass.rnd(200) - 100;
547 }
548 }
549}
AttackSource
Definition: AttackSource.cs:2
FontColor
Definition: FontColor.cs:2
ID_Achievement
virtual void RefreshWeather()
Definition: Card.cs:11
bool IsDecayed
Definition: Card.cs:2357
ElementContainerCard elements
Definition: Card.cs:42
CardRow refCard
Definition: Card.cs:2019
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3277
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6672
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4273
void ChangeWeight(int a)
Definition: Card.cs:2697
void SayNothingHappans()
Definition: Card.cs:7311
void PurgeEythArtifact()
Definition: Card.cs:3456
int Evalue(int ele)
Definition: Card.cs:2704
void CheckJustCooked()
Definition: Card.cs:7101
int Num
Definition: Card.cs:161
SourceCategory.Row category
Definition: Card.cs:2101
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6376
int LV
Definition: Card.cs:389
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9818
Faction faction
Definition: Chara.cs:431
override bool IsPC
Definition: Chara.cs:630
void RemoveAllStances()
Definition: Chara.cs:10219
bool HasCondition(string alias)
Definition: Chara.cs:9990
override int WeightLimit
Definition: Chara.cs:728
void MakeAlly(bool msg=true)
Definition: Chara.cs:2493
Stats mana
Definition: Chara.cs:1213
Stats stamina
Definition: Chara.cs:1205
void RefreshFaithElement()
Definition: Chara.cs:10795
Religion faith
Definition: Chara.cs:443
ConBaseTransmuteMimic mimicry
Definition: Chara.cs:106
void Kill(bool silent=false)
Definition: Condition.cs:108
bool enable
Definition: CoreDebug.cs:301
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Zone _zone
Definition: EClass.cs:21
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static BaseGameScreen screen
Definition: EClass.cs:33
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
static SoundManager Sound
Definition: EClass.cs:47
void Learn(int ele, int v=1)
Element SetBase(string alias, int v, int potential=0)
int id
Definition: ELEMENT.cs:259
ElementContainerFaction charaElements
Definition: FACTION.cs:146
ReligionManager religions
Definition: Game.cs:159
string GetTalk(string id, string idTopic)
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
static string space
Definition: Lang.cs:33
Definition: MOD.cs:7
static GodTalkDataList listGodTalk
Definition: MOD.cs:16
Color TalkGod
Definition: MsgColors.cs:9
Definition: Msg.cs:5
static MsgColors colors
Definition: Msg.cs:20
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
Definition: Point.cs:9
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:624
ReligionStrife Strife
Thing Reforge(string id, Point pos=null, bool first=true)
ReligionMoonShadow MoonShadow
ReligionTrickery Trickery
List< Religion > list
virtual string NameDomain
Definition: Religion.cs:57
bool IsEyth
Definition: Religion.cs:65
virtual string TextType
Definition: Religion.cs:59
virtual void PunishPerverseWretch(Chara c)
Definition: Religion.cs:447
virtual string TextMood
Definition: Religion.cs:63
virtual void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
Definition: Religion.cs:341
bool IsEhekatl
Definition: Religion.cs:67
static Religion recentWrath
Definition: Religion.cs:29
virtual void OnJoinFaith()
Definition: Religion.cs:530
virtual bool IsValidArtifact(string id)
Definition: Religion.cs:322
virtual int GetOfferingMtp(Thing t)
Definition: Religion.cs:186
void DoPunish(Chara c, PunishType type)
Definition: Religion.cs:452
ConvertType
Definition: Religion.cs:8
virtual string TextGodGender
Definition: Religion.cs:61
virtual void PunishTakeOver(Chara c)
Definition: Religion.cs:442
SourceReligion.Row source
Definition: Religion.cs:40
virtual SourceElement.Row GetFeat(int i)
Definition: Religion.cs:75
virtual void Revelation(string idTalk, Card c, int chance=100)
Definition: Religion.cs:167
virtual void Punish(Chara c)
Definition: Religion.cs:437
virtual Sprite GetSprite()
Definition: Religion.cs:93
virtual void OnAdvanceDay()
Definition: Religion.cs:89
int giftRank
Definition: Religion.cs:24
virtual void OnReforge(Thing t)
Definition: Religion.cs:300
bool IsOpatos
Definition: Religion.cs:69
virtual string GetGodTalk(string idTalk)
Definition: Religion.cs:181
virtual bool TryGetGift(Chara chara=null)
Definition: Religion.cs:259
virtual string GetTextBenefit()
Definition: Religion.cs:114
virtual void Talk(string idTalk, Card c=null, Card agent=null)
Definition: Religion.cs:175
virtual bool IsMinorGod
Definition: Religion.cs:71
int relation
Definition: Religion.cs:21
virtual string[] GetValidArtifacts()
Definition: Religion.cs:332
virtual void OnLeaveFaith()
Definition: Religion.cs:534
virtual int GetOfferingValue(Thing t, int num=-1)
Definition: Religion.cs:191
virtual bool IsAvailable
Definition: Religion.cs:35
virtual void OnLoad()
Definition: Religion.cs:85
PunishType
Definition: Religion.cs:14
int mood
Definition: Religion.cs:27
virtual void OnBecomeBranchFaith()
Definition: Religion.cs:337
virtual void Init()
Definition: Religion.cs:80
virtual string NameShort
Definition: Religion.cs:55
virtual void SetTextRelation(UIText text)
Definition: Religion.cs:98
virtual string id
Definition: Religion.cs:33
virtual string GetTextTemper(int _temper=-99999)
Definition: Religion.cs:129
virtual int GetGiftRank(Chara chara=null)
Definition: Religion.cs:241
virtual bool IsFaithElement(Element e)
Definition: Religion.cs:327
virtual bool CanJoin
Definition: Religion.cs:73
virtual void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
Definition: Religion.cs:408
SourceReligion.Row _source
Definition: Religion.cs:31
virtual bool IsIgnoreReforge(Thing t)
Definition: Religion.cs:317
virtual string Name
Definition: Religion.cs:37
virtual void OnChangeHour()
Definition: Religion.cs:538
SourceCategory categories
SourceElement elements
SourceReligion religions
int lv
Definition: Spatial.cs:142
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
SourceThing.Row source
Definition: Thing.cs:11
override int SelfWeight
Definition: Thing.cs:64
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:163
Condition
Definition: Weather.cs:16
Card AddCard(Card t, Point point)
Definition: Zone.cs:2102