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