Elin Decompiled Documentation EA 23.246 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 [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 = "";
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 return source.GetText("textBenefit") + (IsEyth ? "" : "textBenefit".lang(text));
105 }
106
107 public string GetTextTemper(int _temper = -99999)
108 {
109 if (IsEyth)
110 {
111 return "-";
112 }
113 if (_temper == -99999)
114 {
115 _temper = mood;
116 }
117 string[] list = Lang.GetList("temper");
118 if (_temper <= -85)
119 {
120 return list[0].ToTitleCase().TagColor(FontColor.Bad);
121 }
122 if (_temper <= -45)
123 {
124 return list[1].ToTitleCase().TagColor(FontColor.Bad);
125 }
126 if (_temper <= -15)
127 {
128 return list[2].ToTitleCase();
129 }
130 if (_temper < 15)
131 {
132 return list[3].ToTitleCase();
133 }
134 if (_temper < 45)
135 {
136 return list[4].ToTitleCase();
137 }
138 if (_temper < 85)
139 {
140 return list[5].ToTitleCase().TagColor(FontColor.Great);
141 }
142 return list[6].ToTitleCase().TagColor(FontColor.Good);
143 }
144
145 public void Revelation(string idTalk, int chance = 100)
146 {
147 if (!IsEyth && EClass.rnd(100) <= chance)
148 {
149 Talk(idTalk, EClass.pc);
150 }
151 }
152
153 public void Talk(string idTalk, Card c = null, Card agent = null)
154 {
155 if (!IsEyth)
156 {
158 Msg.Say("<i>" + GetGodTalk(idTalk) + " </i>", c ?? EClass.pc);
159 }
160 }
161
162 public string GetGodTalk(string suffix)
163 {
164 return EClass.sources.dataGodTalk.GetText(id, suffix).Split(Environment.NewLine.ToCharArray()).RandomItem();
165 }
166
167 public virtual int GetOfferingMtp(Thing t)
168 {
169 return 0;
170 }
171
172 public int GetOfferingValue(Thing t, int num = -1)
173 {
174 t.CheckJustCooked();
175 if (num == -1)
176 {
177 num = t.Num;
178 }
179 long v = 0L;
180 if (t.source._origin == "meat")
181 {
182 v = Mathf.Clamp(t.SelfWeight / 10, 1, 1000);
183 if (t.refCard == null)
184 {
185 v /= 10L;
186 }
187 }
188 else if (GetOfferingMtp(t) > 0)
189 {
190 SetValue(t.category, GetOfferingMtp(t));
191 }
192 else
193 {
194 string[] cat_offer = source.cat_offer;
195 foreach (string key in cat_offer)
196 {
197 if (t.category.IsChildOf(key))
198 {
199 SetValue(EClass.sources.categories.map[key], 1);
200 break;
201 }
202 }
203 }
204 if (v == 0L)
205 {
206 return 0;
207 }
208 if (t.IsDecayed)
209 {
210 v /= 10L;
211 }
212 v = v * (100 + Mathf.Min(t.LV * 2, 100) + (t.HasElement(757) ? 50 : 0)) / 100;
213 v = (int)Mathf.Clamp(Mathf.Max(v, 1f) * (float)num, 1f, 214748370f);
214 return (int)v;
215 void SetValue(SourceCategory.Row cat, int mtp)
216 {
217 v = Mathf.Clamp(t.SelfWeight / 10, 50, 1000);
218 v *= cat.offer * mtp / 100;
219 }
220 }
221
222 public bool TryGetGift()
223 {
224 if (IsEyth || source.rewards.Length == 0)
225 {
226 return false;
227 }
228 Point point = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false) ?? EClass.pc.pos;
229 int num = EClass.pc.Evalue(85);
230 if (giftRank == 0 && (num >= 15 || EClass.debug.enable))
231 {
232 Talk("pet");
233 Chara chara = CharaGen.Create(source.rewards[0]);
234 EClass._zone.AddCard(chara, point);
235 chara.MakeAlly();
236 chara.PlayEffect("aura_heaven");
237 giftRank = 1;
238 return true;
239 }
240 if (source.rewards.Length >= 2 && giftRank == 1 && (num >= 30 || EClass.debug.enable))
241 {
242 Talk("gift");
243 string[] array = source.rewards[1].Split('|');
244 string[] array2 = array;
245 foreach (string text in array2)
246 {
247 Reforge(text, point, text == array[0]);
248 }
249 giftRank = 2;
250 return true;
251 }
252 return false;
253 }
254
255 public bool IsValidArtifact(string id)
256 {
257 return id switch
258 {
259 "gun_mani" => this == EClass.game.religions.Machine,
260 "cloak_mani" => this == EClass.game.religions.Machine,
261 "scythe_kumi" => this == EClass.game.religions.Harvest,
262 "blunt_earth" => this == EClass.game.religions.Earth,
263 "luckydagger" => this == EClass.game.religions.Luck,
264 "staff_element" => this == EClass.game.religions.Element,
265 "windbow" => this == EClass.game.religions.Wind,
266 "shirt_wind" => this == EClass.game.religions.Wind,
267 "pole_holy" => this == EClass.game.religions.Healing,
268 "sword_muramasa2" => this == EClass.game.religions.MoonShadow,
269 "kogitsunemaru" => this == EClass.game.religions.Trickery,
270 "warmonger" => this == EClass.game.religions.Strife,
271 _ => false,
272 };
273 }
274
275 public static Thing Reforge(string id, Point pos = null, bool first = true)
276 {
277 if (pos == null)
278 {
279 pos = EClass.pc.pos.Copy();
280 }
281 pos.Set(pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? pos);
282 Thing thing = ThingGen.Create(id);
283 foreach (Element value in thing.elements.dict.Values)
284 {
285 if (value.id == 66 || value.id == 67 || value.id == 64 || value.id == 65 || value.id == 92)
286 {
287 continue;
288 }
289 switch (id)
290 {
291 case "gun_mani":
292 thing.c_idDeity = EClass.game.religions.Machine.id;
293 break;
294 case "cloak_mani":
295 if (value.id == 427 || value.id == 957 || value.id == 105 || value.id == 466 || value.id == 664)
296 {
297 value.vExp = -1;
298 }
299 thing.c_idDeity = EClass.game.religions.Machine.id;
300 break;
301 case "scythe_kumi":
302 if (value.id == 6650 || value.id == 480 || value.id == 959 || value.id == 428 || value.id == 640 || value.id == 665)
303 {
304 value.vExp = -1;
305 }
306 thing.c_idDeity = EClass.game.religions.Harvest.id;
307 break;
308 case "blunt_earth":
309 if (value.id == 70 || value.id == 55 || value.id == 56 || value.id == 954 || value.id == 423 || value.id == 421)
310 {
311 value.vExp = -1;
312 }
313 thing.c_idDeity = EClass.game.religions.Earth.id;
314 break;
315 case "luckydagger":
316 if (value.id != 426)
317 {
318 value.vExp = -1;
319 }
320 thing.c_idDeity = EClass.game.religions.Luck.id;
321 break;
322 case "staff_element":
323 if (value.id == 411 || (value is Resistance && value.id != 959))
324 {
325 value.vExp = -1;
326 }
327 thing.c_idDeity = EClass.game.religions.Element.id;
328 break;
329 case "windbow":
330 thing.c_idDeity = EClass.game.religions.Wind.id;
331 break;
332 case "shirt_wind":
333 if (!(value is Resistance) && value.id != 226 && value.id != 152 && value.id != 77)
334 {
335 value.vExp = -1;
336 }
337 thing.c_idDeity = EClass.game.religions.Wind.id;
338 break;
339 case "pole_holy":
340 if (value.id == 60 || value.id == 461 || value.id == 423)
341 {
342 value.vExp = -1;
343 }
344 thing.c_idDeity = EClass.game.religions.Healing.id;
345 break;
346 case "sword_muramasa2":
347 if (value.id == 401 || value.id == 916 || value.id == 661)
348 {
349 value.vExp = -1;
350 }
351 thing.c_idDeity = EClass.game.religions.MoonShadow.id;
352 break;
353 case "kogitsunemaru":
354 if (value.id != 656)
355 {
356 value.vExp = -1;
357 }
358 thing.c_idDeity = EClass.game.religions.Trickery.id;
359 break;
360 case "warmonger":
361 if (value.id == 468 || value.id == 423 || value.id == 463 || value.id == 460 || value.id == 464 || value.id == 465)
362 {
363 value.vExp = -1;
364 }
365 thing.c_idDeity = EClass.game.religions.Strife.id;
366 break;
367 }
368 }
369 EClass._zone.AddCard(thing, pos);
370 pos.PlayEffect("aura_heaven");
371 if (first)
372 {
373 pos.PlaySound("godbless");
374 }
375 return thing;
376 }
377
378 public virtual void OnBecomeBranchFaith()
379 {
380 }
381
382 public void JoinFaith(Chara c, ConvertType type = ConvertType.Default)
383 {
384 if (!c.IsPC)
385 {
386 c.faith = this;
388 EClass.Sound.Play("worship");
389 Msg.Say("changeFaith", c, Name);
390 return;
391 }
392 if (c.faith != this)
393 {
394 c.faith.LeaveFaith(c, this, type);
395 }
396 if (type != ConvertType.Campaign)
397 {
398 EClass.pc.c_daysWithGod = 0;
399 }
400 Msg.Say("worship", Name);
401 Talk("worship", c);
402 EClass.Sound.Play("worship");
403 c.PlayEffect("aura_heaven");
404 c.faith = this;
405 OnJoinFaith();
406 if (IsEyth)
407 {
408 mood = 0;
409 }
410 else
411 {
412 mood = 50;
413 }
415 if (!c.HasElement(306))
416 {
417 c.elements.Learn(306);
418 }
419 if (!c.IsPC)
420 {
421 return;
422 }
424 if (EClass._zone.lv == 0)
425 {
426 if (EClass._zone is Zone_Mifu)
427 {
428 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.Trickery;
430 }
431 if (EClass._zone is Zone_Nefu)
432 {
433 EClass._map.config.blossom = EClass.pc.faith == EClass.game.religions.MoonShadow;
435 }
436 if (EClass._zone is Zone_Aquli)
437 {
438 EClass._map.config.fixedCondition = ((EClass.pc.faith == EClass.game.religions.Strife) ? Weather.Condition.Ether : Weather.Condition.None);
440 }
441 }
443 }
444
445 public void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
446 {
447 if (IsEyth)
448 {
449 return;
450 }
451 bool flag = (newFaith == EClass.game.religions.Trickery && this == EClass.game.religions.MoonShadow) || (newFaith == EClass.game.religions.MoonShadow && this == EClass.game.religions.Trickery);
452 if (c.IsPC)
453 {
454 Msg.Say("worship2");
455 if (!flag && type != ConvertType.Campaign)
456 {
457 Punish(c);
458 }
459 }
460 if (flag)
461 {
462 Talk("regards");
463 c.elements.SetBase(85, c.Evalue(85) / 2);
464 }
465 else
466 {
467 c.elements.SetBase(85, 0);
468 }
469 if (c.IsPC)
470 {
472 }
473 OnLeaveFaith();
475 }
476
477 public void Punish(Chara c)
478 {
479 Talk("wrath");
480 if (c.Evalue(1228) > 0)
481 {
483 return;
484 }
485 c.hp = 1;
486 c.mana.value = 1;
487 c.stamina.value = 1;
488 if (c.HasCondition<ConWrath>())
489 {
490 recentWrath = this;
491 c.DamageHP(999999L, AttackSource.Wrath);
492 recentWrath = null;
493 return;
494 }
495 Thing thing = ThingGen.Create("punish_ball");
496 int num = 0;
498 {
499 if (item.giftRank > 0)
500 {
501 num++;
502 }
503 }
504 if (num >= 4)
505 {
506 thing.idSkin = 1;
507 }
508 thing.ChangeWeight(EClass.pc.WeightLimit / 4 + 1000);
509 c.AddThing(thing);
510 c.AddCondition<ConWrath>(2000 + (c.IsPC ? (EClass.pc.c_daysWithGod * 20) : 0));
511 }
512
513 public void PunishTakeOver(Chara c)
514 {
515 Talk("takeoverFail");
516 if (c.Evalue(1228) > 0)
517 {
519 return;
520 }
521 c.hp /= 2;
522 if (c.mana.value > 0)
523 {
524 c.mana.value = c.mana.value / 2;
525 }
526 if (c.stamina.value > 0)
527 {
528 c.stamina.value = c.stamina.value / 2;
529 }
530 if (c.HasCondition<ConWrath>())
531 {
532 recentWrath = this;
533 c.DamageHP(999999L, AttackSource.Wrath);
534 recentWrath = null;
535 return;
536 }
537 Thing thing = ThingGen.Create("punish_ball");
538 thing.c_weight = EClass.pc.WeightLimit / 4 + 1000;
539 thing.isWeightChanged = true;
540 thing.SetDirtyWeight();
541 c.AddThing(thing);
542 c.AddCondition<ConWrath>(200);
543 }
544
545 public virtual void OnJoinFaith()
546 {
547 }
548
549 public virtual void OnLeaveFaith()
550 {
551 }
552
553 public void OnChangeHour()
554 {
555 if (IsEyth)
556 {
557 mood = 0;
558 }
559 else
560 {
561 mood = EClass.rnd(200) - 100;
562 }
563 }
564}
AttackSource
Definition: AttackSource.cs:2
FontColor
Definition: FontColor.cs:2
virtual void RefreshWeather()
Definition: Card.cs:11
bool IsDecayed
Definition: Card.cs:2287
ElementContainerCard elements
Definition: Card.cs:41
CardRow refCard
Definition: Card.cs:1967
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3104
Point pos
Definition: Card.cs:59
void SetDirtyWeight()
Definition: Card.cs:2554
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6199
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4063
void ChangeWeight(int a)
Definition: Card.cs:2564
void SayNothingHappans()
Definition: Card.cs:6813
void PurgeEythArtifact()
Definition: Card.cs:3278
int Evalue(int ele)
Definition: Card.cs:2571
void CheckJustCooked()
Definition: Card.cs:6624
int Num
Definition: Card.cs:158
SourceCategory.Row category
Definition: Card.cs:2049
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:5920
int LV
Definition: Card.cs:386
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:9244
Faction faction
Definition: Chara.cs:427
override bool IsPC
Definition: Chara.cs:612
bool HasCondition(string alias)
Definition: Chara.cs:9405
override int WeightLimit
Definition: Chara.cs:710
void MakeAlly(bool msg=true)
Definition: Chara.cs:2276
Stats mana
Definition: Chara.cs:1154
Stats stamina
Definition: Chara.cs:1146
void RefreshFaithElement()
Definition: Chara.cs:10184
Religion faith
Definition: Chara.cs:439
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:250
string GetText(string id, string topic="text")
Definition: ExcelData.cs:209
ElementContainerFaction charaElements
Definition: FACTION.cs:146
ReligionManager religions
Definition: Game.cs:158
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:172
bool IsEhekatl
Definition: Religion.cs:46
static Religion recentWrath
Definition: Religion.cs:22
virtual void OnJoinFaith()
Definition: Religion.cs:545
string GetTextBenefit()
Definition: Religion.cs:93
virtual int GetOfferingMtp(Thing t)
Definition: Religion.cs:167
string GetGodTalk(string suffix)
Definition: Religion.cs:162
string GetTextTemper(int _temper=-99999)
Definition: Religion.cs:107
void OnChangeHour()
Definition: Religion.cs:553
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:477
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:145
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:549
virtual bool IsAvailable
Definition: Religion.cs:28
void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
Definition: Religion.cs:382
void LeaveFaith(Chara c, Religion newFaith, ConvertType type)
Definition: Religion.cs:445
Sprite GetSprite()
Definition: Religion.cs:72
int mood
Definition: Religion.cs:20
virtual void OnBecomeBranchFaith()
Definition: Religion.cs:378
void Init()
Definition: Religion.cs:59
static Thing Reforge(string id, Point pos=null, bool first=true)
Definition: Religion.cs:275
void SetTextRelation(UIText text)
Definition: Religion.cs:77
bool TryGetGift()
Definition: Religion.cs:222
virtual string id
Definition: Religion.cs:26
void PunishTakeOver(Chara c)
Definition: Religion.cs:513
void Talk(string idTalk, Card c=null, Card agent=null)
Definition: Religion.cs:153
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:255
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:82
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159
Condition
Definition: Weather.cs:16
Card AddCard(Card t, Point point)
Definition: Zone.cs:1977