Elin Decompiled Documentation EA 23.331 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, int chance = 100)
168 {
169 if (!IsEyth && EClass.rnd(100) <= chance)
170 {
171 Talk(idTalk, EClass.pc);
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()
242 {
243 if (IsEyth || source.rewards.Length == 0)
244 {
245 return -1;
246 }
247 int num = 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()
260 {
261 int num = GetGiftRank();
262 if (num == -1)
263 {
264 return false;
265 }
266 Point point = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass.pc.pos;
267 switch (num)
268 {
269 case 1:
270 {
271 Talk("pet");
272 Chara chara = CharaGen.Create(source.rewards[0]);
273 EClass._zone.AddCard(chara, point);
274 chara.MakeAlly();
275 chara.PlayEffect("aura_heaven");
276 giftRank = 1;
277 return true;
278 }
279 case 2:
280 {
281 Talk("gift");
282 string[] array = source.rewards[1].Split('|');
283 string[] array2 = array;
284 foreach (string text in array2)
285 {
286 EClass.game.religions.Reforge(text, point, text == array[0]);
287 }
288 giftRank = 2;
289 return true;
290 }
291 default:
292 return false;
293 }
294 }
295
296 public virtual void OnReforge(Thing t)
297 {
298 t.c_idDeity = id;
299 if (IsIgnoreReforge(t))
300 {
301 return;
302 }
303 foreach (Element value in t.elements.dict.Values)
304 {
305 int num = value.id;
306 if ((uint)(num - 64) > 3u && num != 92 && IsFaithElement(value))
307 {
308 value.vExp = -1;
309 }
310 }
311 }
312
313 public virtual bool IsIgnoreReforge(Thing t)
314 {
315 return false;
316 }
317
318 public virtual bool IsValidArtifact(string id)
319 {
320 return false;
321 }
322
323 public virtual bool IsFaithElement(Element e)
324 {
325 return false;
326 }
327
328 public virtual string[] GetValidArtifacts()
329 {
330 return Array.Empty<string>();
331 }
332
333 public virtual void OnBecomeBranchFaith()
334 {
335 }
336
337 public virtual void JoinFaith(Chara c, ConvertType type = ConvertType.Default)
338 {
339 if (!c.IsPC)
340 {
341 c.faith = this;
343 EClass.Sound.Play("worship");
344 Msg.Say("changeFaith", c, Name);
345 return;
346 }
347 if (c.faith != this)
348 {
349 c.faith.LeaveFaith(c, this, type);
350 }
351 if (type != ConvertType.Campaign)
352 {
353 EClass.pc.c_daysWithGod = 0;
354 }
355 Msg.Say("worship", Name);
356 Talk("worship", c);
357 EClass.Sound.Play("worship");
358 c.PlayEffect("aura_heaven");
359 c.faith = this;
360 OnJoinFaith();
361 if (IsEyth)
362 {
363 mood = 0;
364 }
365 else
366 {
367 mood = 50;
368 }
370 if (!c.HasElement(306))
371 {
372 c.elements.Learn(306);
373 }
374 if (!c.IsPC)
375 {
376 return;
377 }
379 if (EClass._zone.lv == 0)
380 {
381 if (EClass._zone is Zone_Mifu)
382 {
383 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.Trickery;
385 }
386 if (EClass._zone is Zone_Nefu)
387 {
388 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.MoonShadow;
390 }
391 if (EClass._zone is Zone_Aquli)
392 {
393 EClass._map.config.fixedCondition = ((EClass.pc.faith == EClass.game.religions.Strife) ? Weather.Condition.Ether : Weather.Condition.None);
395 }
396 }
398 if (this is ReligionHealing)
399 {
400 Steam.GetAchievement(ID_Achievement.FAITH_HEALING);
401 }
402 }
403
404 public virtual void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
405 {
406 bool flag = (newFaith == EClass.game.religions.Trickery && this == EClass.game.religions.MoonShadow) || (newFaith == EClass.game.religions.MoonShadow && this == EClass.game.religions.Trickery);
407 if (c.IsPC)
408 {
409 Msg.Say("worship2");
410 if (!flag && type != ConvertType.Campaign)
411 {
412 Punish(c);
413 }
414 }
415 if (flag)
416 {
417 Talk("regards");
418 c.elements.SetBase(85, c.Evalue(85) / 2);
419 }
420 else
421 {
422 c.elements.SetBase(85, 0);
423 }
425 if (c.IsPC)
426 {
428 }
429 OnLeaveFaith();
431 }
432
433 public virtual void Punish(Chara c)
434 {
435 DoPunish(c, PunishType.Wrath);
436 }
437
438 public virtual void PunishTakeOver(Chara c)
439 {
440 DoPunish(c, PunishType.Takeover);
441 }
442
443 public virtual void PunishPerverseWretch(Chara c)
444 {
445 DoPunish(c, PunishType.Pervert);
446 }
447
448 public void DoPunish(Chara c, PunishType type)
449 {
450 if (c.mimicry != null)
451 {
452 c.mimicry.Kill();
453 }
454 Talk((type == PunishType.Takeover) ? "takeoverFail" : "wrath");
455 if (type == PunishType.Wrath && c.Evalue(1228) > 0)
456 {
458 return;
459 }
460 if (type == PunishType.Wrath)
461 {
462 c.hp = 1;
463 if (c.mana.value > 0)
464 {
465 c.mana.value = 1;
466 }
467 if (c.stamina.value > 0)
468 {
469 c.stamina.value = 1;
470 }
471 }
472 else
473 {
474 c.hp /= 2;
475 if (c.mana.value > 0)
476 {
477 c.mana.value = c.mana.value / 2;
478 }
479 if (c.stamina.value > 0)
480 {
481 c.stamina.value = c.stamina.value / 2;
482 }
483 }
484 if (c.HasCondition<ConWrath>())
485 {
486 recentWrath = this;
487 c.DamageHP(99999999L, AttackSource.Wrath);
488 recentWrath = null;
489 return;
490 }
491 Thing thing = ThingGen.Create("punish_ball");
492 int p = 100;
493 switch (type)
494 {
495 case PunishType.Wrath:
496 {
497 p = 2000 + (c.IsPC ? (EClass.pc.c_daysWithGod * 20) : 0);
498 if (type != 0)
499 {
500 break;
501 }
502 int num = 0;
504 {
505 if (item.giftRank > 0)
506 {
507 num++;
508 }
509 }
510 if (num >= 4)
511 {
512 thing.idSkin = 1;
513 }
514 break;
515 }
516 case PunishType.Takeover:
517 case PunishType.Pervert:
518 p = 200;
519 break;
520 }
521 thing.ChangeWeight(EClass.pc.WeightLimit / 4 + 1000);
522 c.AddThing(thing);
524 }
525
526 public virtual void OnJoinFaith()
527 {
528 }
529
530 public virtual void OnLeaveFaith()
531 {
532 }
533
534 public virtual void OnChangeHour()
535 {
536 if (IsEyth)
537 {
538 mood = 0;
539 }
540 else
541 {
542 mood = EClass.rnd(200) - 100;
543 }
544 }
545}
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:3273
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6647
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4269
void ChangeWeight(int a)
Definition: Card.cs:2697
void SayNothingHappans()
Definition: Card.cs:7286
void PurgeEythArtifact()
Definition: Card.cs:3452
int Evalue(int ele)
Definition: Card.cs:2704
void CheckJustCooked()
Definition: Card.cs:7076
int Num
Definition: Card.cs:161
SourceCategory.Row category
Definition: Card.cs:2101
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6351
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:9773
Faction faction
Definition: Chara.cs:431
override bool IsPC
Definition: Chara.cs:630
void RemoveAllStances()
Definition: Chara.cs:10166
bool HasCondition(string alias)
Definition: Chara.cs:9938
override int WeightLimit
Definition: Chara.cs:728
void MakeAlly(bool msg=true)
Definition: Chara.cs:2478
Stats mana
Definition: Chara.cs:1213
Stats stamina
Definition: Chara.cs:1205
void RefreshFaithElement()
Definition: Chara.cs:10742
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 Revelation(string idTalk, int chance=100)
Definition: Religion.cs:167
virtual void PunishPerverseWretch(Chara c)
Definition: Religion.cs:443
virtual string TextMood
Definition: Religion.cs:63
virtual void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
Definition: Religion.cs:337
bool IsEhekatl
Definition: Religion.cs:67
static Religion recentWrath
Definition: Religion.cs:29
virtual void OnJoinFaith()
Definition: Religion.cs:526
virtual bool IsValidArtifact(string id)
Definition: Religion.cs:318
virtual int GetOfferingMtp(Thing t)
Definition: Religion.cs:186
void DoPunish(Chara c, PunishType type)
Definition: Religion.cs:448
virtual int GetGiftRank()
Definition: Religion.cs:241
ConvertType
Definition: Religion.cs:8
virtual string TextGodGender
Definition: Religion.cs:61
virtual void PunishTakeOver(Chara c)
Definition: Religion.cs:438
SourceReligion.Row source
Definition: Religion.cs:40
virtual SourceElement.Row GetFeat(int i)
Definition: Religion.cs:75
virtual void Punish(Chara c)
Definition: Religion.cs:433
virtual bool TryGetGift()
Definition: Religion.cs:259
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:296
bool IsOpatos
Definition: Religion.cs:69
virtual string GetGodTalk(string idTalk)
Definition: Religion.cs:181
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:328
virtual void OnLeaveFaith()
Definition: Religion.cs:530
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:333
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 bool IsFaithElement(Element e)
Definition: Religion.cs:323
virtual bool CanJoin
Definition: Religion.cs:73
virtual void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
Definition: Religion.cs:404
SourceReligion.Row _source
Definition: Religion.cs:31
virtual bool IsIgnoreReforge(Thing t)
Definition: Religion.cs:313
virtual string Name
Definition: Religion.cs:37
virtual void OnChangeHour()
Definition: Religion.cs:534
SourceCategory categories
SourceElement elements
SourceReligion religions
int lv
Definition: Spatial.cs:142
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
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:2090