Elin Decompiled Documentation EA 23.279 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 string Name => source.GetName();
31
33
34 public string NameShort => source.GetTextArray("name2")[1];
35
36 public string NameDomain => source.GetTextArray("name2")[0];
37
38 public string TextType => ("sub_" + source.type).lang();
39
40 public string TextGodGender => source.GetText("textType");
41
42 public string TextMood => GetTextTemper();
43
44 public bool IsEyth => id == "eyth";
45
46 public bool IsEhekatl => id == "luck";
47
48 public bool IsOpatos => id == "earth";
49
50 public virtual bool IsMinorGod => false;
51
52 public virtual bool CanJoin => true;
53
54 public virtual SourceElement.Row GetFeat(int i)
55 {
56 return EClass.sources.elements.alias["featGod_" + id + i];
57 }
58
59 public void Init()
60 {
61 relation = source.relation;
62 }
63
64 public void OnLoad()
65 {
66 }
67
68 public void OnAdvanceDay()
69 {
70 }
71
72 public Sprite GetSprite()
73 {
74 return ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/" + source.id) ?? ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/eyth");
75 }
76
77 public void SetTextRelation(UIText text)
78 {
79 if (relation > 100)
80 {
81 text.SetText("reFriend".lang(), FontColor.Good);
82 }
83 else if (relation < -100)
84 {
85 text.SetText("reEnemy".lang(), FontColor.Bad);
86 }
87 else
88 {
89 text.SetText("reNone".lang(), FontColor.Passive);
90 }
91 }
92
93 public string GetTextBenefit()
94 {
95 string text = "<color=green>";
96 for (int i = 0; i < source.elements.Length; i += 2)
97 {
98 if (i != 0)
99 {
100 text = text + Lang.words.comma + Lang.space;
101 }
102 text += EClass.sources.elements.map[source.elements[i]].GetName();
103 }
104 text += "</color>";
105 return source.GetText("textBenefit") + Environment.NewLine + Environment.NewLine + (IsEyth ? "" : "textBenefit".lang(text));
106 }
107
108 public string GetTextTemper(int _temper = -99999)
109 {
110 if (IsEyth)
111 {
112 return "-";
113 }
114 if (_temper == -99999)
115 {
116 _temper = mood;
117 }
118 string[] list = Lang.GetList("temper");
119 if (_temper <= -85)
120 {
121 return list[0].ToTitleCase().TagColor(FontColor.Bad);
122 }
123 if (_temper <= -45)
124 {
125 return list[1].ToTitleCase().TagColor(FontColor.Bad);
126 }
127 if (_temper <= -15)
128 {
129 return list[2].ToTitleCase();
130 }
131 if (_temper < 15)
132 {
133 return list[3].ToTitleCase();
134 }
135 if (_temper < 45)
136 {
137 return list[4].ToTitleCase();
138 }
139 if (_temper < 85)
140 {
141 return list[5].ToTitleCase().TagColor(FontColor.Great);
142 }
143 return list[6].ToTitleCase().TagColor(FontColor.Good);
144 }
145
146 public void Revelation(string idTalk, int chance = 100)
147 {
148 if (!IsEyth && EClass.rnd(100) <= chance)
149 {
150 Talk(idTalk, EClass.pc);
151 }
152 }
153
154 public void Talk(string idTalk, Card c = null, Card agent = null)
155 {
157 Msg.Say("<i>" + GetGodTalk(idTalk) + " </i>", c ?? EClass.pc);
158 }
159
160 public string GetGodTalk(string suffix)
161 {
162 return EClass.sources.dataGodTalk.GetText(id, suffix).Split(Environment.NewLine.ToCharArray()).RandomItem();
163 }
164
165 public virtual int GetOfferingMtp(Thing t)
166 {
167 return 0;
168 }
169
170 public int GetOfferingValue(Thing t, int num = -1)
171 {
172 t.CheckJustCooked();
173 if (num == -1)
174 {
175 num = t.Num;
176 }
177 long v = 0L;
178 if (t.source._origin == "meat")
179 {
180 v = Mathf.Clamp(t.SelfWeight / 10, 1, 1000);
181 if (t.refCard == null)
182 {
183 v /= 10L;
184 }
185 }
186 else if (GetOfferingMtp(t) > 0)
187 {
188 SetValue(t.category, GetOfferingMtp(t));
189 }
190 else
191 {
192 string[] cat_offer = source.cat_offer;
193 foreach (string key in cat_offer)
194 {
195 if (t.category.IsChildOf(key))
196 {
197 SetValue(EClass.sources.categories.map[key], 1);
198 break;
199 }
200 }
201 }
202 if (v == 0L)
203 {
204 return 0;
205 }
206 if (t.IsDecayed)
207 {
208 v /= 10L;
209 }
210 v = v * (100 + Mathf.Min(t.LV * 2, 100) + (t.HasElement(757) ? 50 : 0)) / 100;
211 v = (int)Mathf.Clamp(Mathf.Max(v, 1f) * (float)num, 1f, 214748370f);
212 return (int)v;
213 void SetValue(SourceCategory.Row cat, int mtp)
214 {
215 v = Mathf.Clamp(t.SelfWeight / 10, 50, 1000);
216 v *= cat.offer * mtp / 100;
217 }
218 }
219
220 public int GetGiftRank()
221 {
222 if (IsEyth || source.rewards.Length == 0)
223 {
224 return -1;
225 }
226 int num = EClass.pc.Evalue(85);
227 if (giftRank == 0 && (num >= 15 || EClass.debug.enable))
228 {
229 return 1;
230 }
231 if (source.rewards.Length >= 2 && giftRank == 1 && (num >= 30 || EClass.debug.enable))
232 {
233 return 2;
234 }
235 return -1;
236 }
237
238 public bool TryGetGift()
239 {
240 int num = GetGiftRank();
241 if (num == -1)
242 {
243 return false;
244 }
245 Point point = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass.pc.pos;
246 switch (num)
247 {
248 case 1:
249 {
250 Talk("pet");
251 Chara chara = CharaGen.Create(source.rewards[0]);
252 EClass._zone.AddCard(chara, point);
253 chara.MakeAlly();
254 chara.PlayEffect("aura_heaven");
255 giftRank = 1;
256 return true;
257 }
258 case 2:
259 {
260 Talk("gift");
261 string[] array = source.rewards[1].Split('|');
262 string[] array2 = array;
263 foreach (string text in array2)
264 {
265 Reforge(text, point, text == array[0]);
266 }
267 giftRank = 2;
268 return true;
269 }
270 default:
271 return false;
272 }
273 }
274
275 public static Religion GetArtifactDeity(string id)
276 {
277 return id switch
278 {
279 "gun_mani" => EClass.game.religions.Machine,
280 "cloak_mani" => EClass.game.religions.Machine,
281 "scythe_kumi" => EClass.game.religions.Harvest,
282 "blunt_earth" => EClass.game.religions.Earth,
283 "luckydagger" => EClass.game.religions.Luck,
284 "staff_element" => EClass.game.religions.Element,
285 "windbow" => EClass.game.religions.Wind,
286 "shirt_wind" => EClass.game.religions.Wind,
287 "pole_holy" => EClass.game.religions.Healing,
288 "sword_muramasa2" => EClass.game.religions.MoonShadow,
289 "kogitsunemaru" => EClass.game.religions.Trickery,
290 "warmonger" => EClass.game.religions.Strife,
291 _ => null,
292 };
293 }
294
295 public bool IsValidArtifact(string id)
296 {
297 return this == GetArtifactDeity(id);
298 }
299
300 public static Thing Reforge(string id, Point pos = null, bool first = true)
301 {
302 if (pos == null)
303 {
304 pos = EClass.pc.pos.Copy();
305 }
306 pos.Set(pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? pos);
307 Thing thing = ThingGen.Create(id);
308 foreach (Element value in thing.elements.dict.Values)
309 {
310 if (value.id == 66 || value.id == 67 || value.id == 64 || value.id == 65 || value.id == 92)
311 {
312 continue;
313 }
314 switch (id)
315 {
316 case "gun_mani":
317 thing.c_idDeity = EClass.game.religions.Machine.id;
318 break;
319 case "cloak_mani":
320 if (value.id == 427 || value.id == 957 || value.id == 105 || value.id == 466 || value.id == 664)
321 {
322 value.vExp = -1;
323 }
324 thing.c_idDeity = EClass.game.religions.Machine.id;
325 break;
326 case "scythe_kumi":
327 if (value.id == 6650 || value.id == 480 || value.id == 959 || value.id == 428 || value.id == 640 || value.id == 665)
328 {
329 value.vExp = -1;
330 }
331 thing.c_idDeity = EClass.game.religions.Harvest.id;
332 break;
333 case "blunt_earth":
334 if (value.id == 70 || value.id == 55 || value.id == 56 || value.id == 954 || value.id == 423 || value.id == 421)
335 {
336 value.vExp = -1;
337 }
338 thing.c_idDeity = EClass.game.religions.Earth.id;
339 break;
340 case "luckydagger":
341 if (value.id != 426)
342 {
343 value.vExp = -1;
344 }
345 thing.c_idDeity = EClass.game.religions.Luck.id;
346 break;
347 case "staff_element":
348 if (value.id == 411 || (value is Resistance && value.id != 959))
349 {
350 value.vExp = -1;
351 }
352 thing.c_idDeity = EClass.game.religions.Element.id;
353 break;
354 case "windbow":
355 thing.c_idDeity = EClass.game.religions.Wind.id;
356 break;
357 case "shirt_wind":
358 if (!(value is Resistance) && value.id != 226 && value.id != 152 && value.id != 77)
359 {
360 value.vExp = -1;
361 }
362 thing.c_idDeity = EClass.game.religions.Wind.id;
363 break;
364 case "pole_holy":
365 if (value.id == 60 || value.id == 461 || value.id == 423)
366 {
367 value.vExp = -1;
368 }
369 thing.c_idDeity = EClass.game.religions.Healing.id;
370 break;
371 case "sword_muramasa2":
372 if (value.id == 401 || value.id == 916 || value.id == 661)
373 {
374 value.vExp = -1;
375 }
376 thing.c_idDeity = EClass.game.religions.MoonShadow.id;
377 break;
378 case "kogitsunemaru":
379 if (value.id != 656)
380 {
381 value.vExp = -1;
382 }
383 thing.c_idDeity = EClass.game.religions.Trickery.id;
384 break;
385 case "warmonger":
386 if (value.id == 468 || value.id == 423 || value.id == 463 || value.id == 460 || value.id == 464 || value.id == 465)
387 {
388 value.vExp = -1;
389 }
390 thing.c_idDeity = EClass.game.religions.Strife.id;
391 break;
392 }
393 }
394 EClass._zone.AddCard(thing, pos);
395 pos.PlayEffect("aura_heaven");
396 if (first)
397 {
398 pos.PlaySound("godbless");
399 }
400 return thing;
401 }
402
403 public virtual void OnBecomeBranchFaith()
404 {
405 }
406
407 public void JoinFaith(Chara c, ConvertType type = ConvertType.Default)
408 {
409 if (!c.IsPC)
410 {
411 c.faith = this;
413 EClass.Sound.Play("worship");
414 Msg.Say("changeFaith", c, Name);
415 return;
416 }
417 if (c.faith != this)
418 {
419 c.faith.LeaveFaith(c, this, type);
420 }
421 if (type != ConvertType.Campaign)
422 {
423 EClass.pc.c_daysWithGod = 0;
424 }
425 Msg.Say("worship", Name);
426 Talk("worship", c);
427 EClass.Sound.Play("worship");
428 c.PlayEffect("aura_heaven");
429 c.faith = this;
430 OnJoinFaith();
431 if (IsEyth)
432 {
433 mood = 0;
434 }
435 else
436 {
437 mood = 50;
438 }
440 if (!c.HasElement(306))
441 {
442 c.elements.Learn(306);
443 }
444 if (!c.IsPC)
445 {
446 return;
447 }
449 if (EClass._zone.lv == 0)
450 {
451 if (EClass._zone is Zone_Mifu)
452 {
453 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.Trickery;
455 }
456 if (EClass._zone is Zone_Nefu)
457 {
458 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.MoonShadow;
460 }
461 if (EClass._zone is Zone_Aquli)
462 {
463 EClass._map.config.fixedCondition = ((EClass.pc.faith == EClass.game.religions.Strife) ? Weather.Condition.Ether : Weather.Condition.None);
465 }
466 }
468 }
469
470 public void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
471 {
472 if (!IsEyth)
473 {
474 bool flag = (newFaith == EClass.game.religions.Trickery && this == EClass.game.religions.MoonShadow) || (newFaith == EClass.game.religions.MoonShadow && this == EClass.game.religions.Trickery);
475 if (c.IsPC)
476 {
477 Msg.Say("worship2");
478 if (!flag && type != ConvertType.Campaign)
479 {
480 Punish(c);
481 }
482 }
483 if (flag)
484 {
485 Talk("regards");
486 c.elements.SetBase(85, c.Evalue(85) / 2);
487 }
488 else
489 {
490 c.elements.SetBase(85, 0);
491 }
492 }
493 if (c.IsPC)
494 {
496 }
497 OnLeaveFaith();
499 }
500
501 public void Punish(Chara c)
502 {
503 if (c.mimicry != null)
504 {
505 c.mimicry.Kill();
506 }
507 Talk("wrath");
508 if (c.Evalue(1228) > 0)
509 {
511 return;
512 }
513 c.hp = 1;
514 c.mana.value = 1;
515 c.stamina.value = 1;
516 if (c.HasCondition<ConWrath>())
517 {
518 recentWrath = this;
519 c.DamageHP(999999L, AttackSource.Wrath);
520 recentWrath = null;
521 return;
522 }
523 Thing thing = ThingGen.Create("punish_ball");
524 int num = 0;
526 {
527 if (item.giftRank > 0)
528 {
529 num++;
530 }
531 }
532 if (num >= 4)
533 {
534 thing.idSkin = 1;
535 }
536 thing.ChangeWeight(EClass.pc.WeightLimit / 4 + 1000);
537 c.AddThing(thing);
538 c.AddCondition<ConWrath>(2000 + (c.IsPC ? (EClass.pc.c_daysWithGod * 20) : 0));
539 }
540
541 public void PunishTakeOver(Chara c)
542 {
543 if (c.mimicry != null)
544 {
545 c.mimicry.Kill();
546 }
547 Talk("takeoverFail");
548 if (c.Evalue(1228) > 0)
549 {
551 return;
552 }
553 c.hp /= 2;
554 if (c.mana.value > 0)
555 {
556 c.mana.value = c.mana.value / 2;
557 }
558 if (c.stamina.value > 0)
559 {
560 c.stamina.value = c.stamina.value / 2;
561 }
562 if (c.HasCondition<ConWrath>())
563 {
564 recentWrath = this;
565 c.DamageHP(999999L, AttackSource.Wrath);
566 recentWrath = null;
567 return;
568 }
569 Thing thing = ThingGen.Create("punish_ball");
570 thing.c_weight = EClass.pc.WeightLimit / 4 + 1000;
571 thing.isWeightChanged = true;
572 thing.SetDirtyWeight();
573 c.AddThing(thing);
574 c.AddCondition<ConWrath>(200);
575 }
576
577 public virtual void OnJoinFaith()
578 {
579 }
580
581 public virtual void OnLeaveFaith()
582 {
583 }
584
585 public void OnChangeHour()
586 {
587 if (IsEyth)
588 {
589 mood = 0;
590 }
591 else
592 {
593 mood = EClass.rnd(200) - 100;
594 }
595 }
596}
AttackSource
Definition: AttackSource.cs:2
FontColor
Definition: FontColor.cs:2
virtual void RefreshWeather()
Definition: Card.cs:11
bool IsDecayed
Definition: Card.cs:2315
ElementContainerCard elements
Definition: Card.cs:42
CardRow refCard
Definition: Card.cs:1993
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3152
Point pos
Definition: Card.cs:60
void SetDirtyWeight()
Definition: Card.cs:2582
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6377
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4117
void ChangeWeight(int a)
Definition: Card.cs:2592
void SayNothingHappans()
Definition: Card.cs:7015
void PurgeEythArtifact()
Definition: Card.cs:3332
int Evalue(int ele)
Definition: Card.cs:2599
void CheckJustCooked()
Definition: Card.cs:6806
int Num
Definition: Card.cs:159
SourceCategory.Row category
Definition: Card.cs:2075
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6090
int LV
Definition: Card.cs:387
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:9407
Faction faction
Definition: Chara.cs:429
override bool IsPC
Definition: Chara.cs:626
bool HasCondition(string alias)
Definition: Chara.cs:9568
override int WeightLimit
Definition: Chara.cs:724
ConTransmuteMimic mimicry
Definition: Chara.cs:106
void MakeAlly(bool msg=true)
Definition: Chara.cs:2322
Stats mana
Definition: Chara.cs:1180
Stats stamina
Definition: Chara.cs:1172
void RefreshFaithElement()
Definition: Chara.cs:10360
Religion faith
Definition: Chara.cs:441
void Kill(bool silent=false)
Definition: Condition.cs:91
bool enable
Definition: CoreDebug.cs:286
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:255
string GetText(string id, string topic="text")
Definition: ExcelData.cs:209
ElementContainerFaction charaElements
Definition: FACTION.cs:146
ReligionManager religions
Definition: Game.cs:159
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
static string space
Definition: Lang.cs:32
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 Copy()
Definition: Point.cs:491
Point Set(int _x, int _z)
Definition: Point.cs:503
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:619
override string id
Definition: ReligionEarth.cs:3
override string id
override string id
override string id
override string id
Definition: ReligionLuck.cs:3
override string id
ReligionWind Wind
ReligionHarvest Harvest
ReligionMachine Machine
ReligionLuck Luck
ReligionStrife Strife
ReligionMoonShadow MoonShadow
ReligionTrickery Trickery
ReligionElement Element
List< Religion > list
ReligionEarth Earth
ReligionHealing Healing
override string id
override string id
override string id
override string id
Definition: ReligionWind.cs:3
string NameDomain
Definition: Religion.cs:36
string Name
Definition: Religion.cs:30
bool IsEyth
Definition: Religion.cs:44
string TextType
Definition: Religion.cs:38
int GetOfferingValue(Thing t, int num=-1)
Definition: Religion.cs:170
bool IsEhekatl
Definition: Religion.cs:46
static Religion recentWrath
Definition: Religion.cs:22
virtual void OnJoinFaith()
Definition: Religion.cs:577
string GetTextBenefit()
Definition: Religion.cs:93
virtual int GetOfferingMtp(Thing t)
Definition: Religion.cs:165
string GetGodTalk(string suffix)
Definition: Religion.cs:160
string GetTextTemper(int _temper=-99999)
Definition: Religion.cs:108
void OnChangeHour()
Definition: Religion.cs:585
ConvertType
Definition: Religion.cs:8
SourceReligion.Row source
Definition: Religion.cs:32
virtual SourceElement.Row GetFeat(int i)
Definition: Religion.cs:54
void Punish(Chara c)
Definition: Religion.cs:501
string TextGodGender
Definition: Religion.cs:40
int giftRank
Definition: Religion.cs:17
string TextMood
Definition: Religion.cs:42
void Revelation(string idTalk, int chance=100)
Definition: Religion.cs:146
bool IsOpatos
Definition: Religion.cs:48
virtual bool IsMinorGod
Definition: Religion.cs:50
int relation
Definition: Religion.cs:14
virtual void OnLeaveFaith()
Definition: Religion.cs:581
virtual bool IsAvailable
Definition: Religion.cs:28
void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
Definition: Religion.cs:407
void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
Definition: Religion.cs:470
Sprite GetSprite()
Definition: Religion.cs:72
int mood
Definition: Religion.cs:20
virtual void OnBecomeBranchFaith()
Definition: Religion.cs:403
void Init()
Definition: Religion.cs:59
static Thing Reforge(string id, Point pos=null, bool first=true)
Definition: Religion.cs:300
void SetTextRelation(UIText text)
Definition: Religion.cs:77
bool TryGetGift()
Definition: Religion.cs:238
virtual string id
Definition: Religion.cs:26
void PunishTakeOver(Chara c)
Definition: Religion.cs:541
void Talk(string idTalk, Card c=null, Card agent=null)
Definition: Religion.cs:154
void OnLoad()
Definition: Religion.cs:64
virtual bool CanJoin
Definition: Religion.cs:52
SourceReligion.Row _source
Definition: Religion.cs:24
string NameShort
Definition: Religion.cs:34
bool IsValidArtifact(string id)
Definition: Religion.cs:295
int GetGiftRank()
Definition: Religion.cs:220
static Religion GetArtifactDeity(string id)
Definition: Religion.cs:275
void OnAdvanceDay()
Definition: Religion.cs:68
ExcelData dataGodTalk
SourceCategory categories
SourceElement elements
SourceReligion religions
int lv
Definition: Spatial.cs:142
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
SourceThing.Row source
Definition: Thing.cs:11
override int SelfWeight
Definition: Thing.cs:67
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:1994