Elin Decompiled Documentation EA 23.350.1 Nightly
Loading...
Searching...
No Matches
Chara.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using Algorithms;
6using Newtonsoft.Json;
7using UnityEngine;
8
9public class Chara : Card, IPathfindWalker
10{
11 private static Point shared = new Point();
12
13 private static List<Hobby> listHobby = new List<Hobby>();
14
15 public static string[] IDTimeTable = new string[2] { "default", "owl" };
16
17 [JsonProperty]
18 public int contribution;
19
20 [JsonProperty]
21 public Point orgPos;
22
23 [JsonProperty]
24 public Quest quest;
25
26 [JsonProperty]
27 public Chara ride;
28
29 [JsonProperty]
31
32 [JsonProperty]
33 public Chara host;
34
35 [JsonProperty]
37
39
41
42 [JsonProperty(PropertyName = "T1")]
43 public Party party;
44
45 [JsonProperty(PropertyName = "T2")]
47
48 [JsonProperty(PropertyName = "T3")]
49 public List<int> _hobbies;
50
51 [JsonProperty(PropertyName = "T4")]
52 public List<int> _works;
53
54 [JsonProperty(PropertyName = "T5")]
56
57 [JsonProperty(PropertyName = "T6")]
58 public List<int> _cooldowns;
59
60 [JsonProperty(PropertyName = "T7")]
61 public List<int> _listAbility;
62
63 [JsonProperty(PropertyName = "T8")]
64 public List<List<string>> _historyFood;
65
66 [JsonProperty(PropertyName = "1")]
67 public PCCData pccData;
68
69 [JsonProperty(PropertyName = "2")]
70 public Card held;
71
72 [JsonProperty(PropertyName = "3")]
73 public int[] rawSlots;
74
75 [JsonProperty(PropertyName = "4")]
77
78 [JsonProperty(PropertyName = "8")]
79 public string[] _strs = new string[5];
80
81 [JsonProperty(PropertyName = "9")]
82 public int[] _cints = new int[30];
83
85
86 public Chara enemy;
87
88 public Chara master;
89
90 public new Point lastPos = new Point();
91
93
94 public CharaBody body = new CharaBody();
95
97
98 public Thing ranged;
99
101
103
105
107
108 public Emo2 emoIcon;
109
110 public int happiness;
111
112 public int turnLastSeen = -100;
113
114 public int idleActTimer;
115
116 public int combatCount;
117
118 public int calmCheckTurn;
119
120 public int sharedCheckTurn;
121
122 public float idleTimer;
123
124 public bool isBerserk;
125
126 public bool isDrunk;
127
128 public bool isConfused;
129
130 public bool isFainted;
131
132 public bool isBlind;
133
134 public bool isParalyzed;
135
136 public bool _isLevitating;
137
138 public bool isCreated;
139
140 public bool canSeeInvisible;
141
142 public bool hasTelepathy;
143
144 public bool isWet;
145
146 public bool bossText;
147
148 public bool ignoreSPAbsorb;
149
150 public bool wasInWater;
151
153
154 public bool isWeakToSunlight;
155
156 public bool isAstralBody;
157
159
161
163
165
167
169
170 public static List<SourceRace.Row> ListAdvRace = new List<SourceRace.Row>();
171
172 public static List<SourceJob.Row> ListAdvJob = new List<SourceJob.Row>();
173
174 public bool dirtySpeed = true;
175
176 private long _Speed;
177
178 private static Point _sharedPos = new Point();
179
180 private bool hasMovedThisTurn;
181
182 public float actTime = 0.3f;
183
184 public static bool consumeTurn;
185
186 public static bool preventRegen;
187
188 public static bool isOnCreate;
189
190 private static List<Chara> _pts = new List<Chara>();
191
192 public int stealthSeen;
193
194 private static List<Thing> _ListItems = new List<Thing>();
195
196 private static List<SourceThing.Row> _listFavFood = new List<SourceThing.Row>();
197
198 private static List<SourceCategory.Row> _listFavCat = new List<SourceCategory.Row>();
199
200 public static NoGoal _NoGoalPC = new NoGoal();
201
202 public static NoGoal _NoGoalRepeat = new NoGoal();
203
204 public GoalList goalList = new GoalList();
205
206 public AIAct ai = new NoGoal();
207
209
210 private static GoalWork _goalWork = new GoalWork();
211
212 private static GoalHobby _goalHobby = new GoalHobby();
213
214 [JsonProperty]
215 public List<Condition> conditions = new List<Condition>();
216
217 [JsonProperty]
218 public Dictionary<int, int> resistCon;
219
220 public string Aka => _alias.IsEmpty(source.GetText("aka", returnNull: true) ?? "");
221
222 public string _alias
223 {
224 get
225 {
226 return _strs[0];
227 }
228 set
229 {
230 _strs[0] = value;
231 }
232 }
233
234 public string idFaith
235 {
236 get
237 {
238 return _strs[1];
239 }
240 set
241 {
242 _strs[1] = value;
243 }
244 }
245
246 public string idFaction
247 {
248 get
249 {
250 return _strs[2];
251 }
252 set
253 {
254 _strs[2] = value;
255 }
256 }
257
259 {
260 get
261 {
262 return RefZone.Get(_cints[1]);
263 }
264 set
265 {
266 _cints[1] = RefZone.Set(value);
267 }
268 }
269
271 {
272 get
273 {
274 return RefZone.Get(_cints[2]);
275 }
276 set
277 {
278 _cints[2] = RefZone.Set(value);
279 }
280 }
281
283 {
284 get
285 {
286 return _cints[3].ToEnum<GoalListType>();
287 }
288 set
289 {
290 _cints[3] = (int)value;
291 }
292 }
293
295 {
296 get
297 {
298 return _cints[4].ToEnum<Hostility>();
299 }
300 set
301 {
302 _cints[4] = (int)value;
303 }
304 }
305
306 public int _affinity
307 {
308 get
309 {
310 return _cints[5];
311 }
312 set
313 {
314 _cints[5] = value;
315 }
316 }
317
318 public Affinity affinity => Affinity.Get(this);
319
320 public int interest
321 {
322 get
323 {
324 return _cints[6];
325 }
326 set
327 {
328 _cints[6] = value;
329 }
330 }
331
332 public int daysStarved
333 {
334 get
335 {
336 return _cints[7];
337 }
338 set
339 {
340 _cints[7] = value;
341 }
342 }
343
344 public int _idTimeTable
345 {
346 get
347 {
348 return _cints[9];
349 }
350 set
351 {
352 _cints[9] = value;
353 }
354 }
355
356 public int uidEditor
357 {
358 get
359 {
360 return _cints[10];
361 }
362 set
363 {
364 _cints[10] = value;
365 }
366 }
367
368 public int _maxStamina
369 {
370 get
371 {
372 return _cints[20];
373 }
374 set
375 {
376 _cints[20] = value;
377 }
378 }
379
380 public int corruption
381 {
382 get
383 {
384 return _cints[21];
385 }
386 set
387 {
388 _cints[21] = value;
389 }
390 }
391
392 public bool isDead
393 {
394 get
395 {
396 return _cbits1[0];
397 }
398 set
399 {
400 _cbits1[0] = value;
401 }
402 }
403
404 public bool isAlawysVisible
405 {
406 get
407 {
408 return _cbits1[1];
409 }
410 set
411 {
412 _cbits1[1] = value;
413 }
414 }
415
416 public bool knowFav
417 {
418 get
419 {
420 return _cbits1[3];
421 }
422 set
423 {
424 _cbits1[3] = value;
425 }
426 }
427
429
431 {
432 get
433 {
434 return _faction ?? (_faction = EClass.game.factions.dictAll.TryGetValue(idFaction));
435 }
436 set
437 {
438 idFaction = value?.uid;
439 }
440 }
441
443 {
444 get
445 {
446 return EClass.game.religions.dictAll.TryGetValue(idFaith) ?? EClass.game.religions.dictAll["eyth"];
447 }
448 set
449 {
450 idFaith = value?.id;
451 }
452 }
453
454 public override CardRow sourceCard => source;
455
456 public override CardRow sourceRenderCard
457 {
458 get
459 {
460 if (pccData != null && !(source.renderData is RenderDataPcc))
461 {
463 }
464 return source;
465 }
466 }
467
468 public SourceRace.Row race => _race ?? (_race = EClass.sources.races.map.TryGetValue(base.c_idRace.IsEmpty(source.race))) ?? EClass.sources.races.map["norland"];
469
470 public SourceJob.Row job => _job ?? (_job = EClass.sources.jobs.map.TryGetValue(base.c_idJob.IsEmpty(source.job))) ?? EClass.sources.jobs.map["none"];
471
473
475 {
476 get
477 {
478 if (EClass.pc == null || !IsPCFaction)
479 {
480 if (base.c_originalHostility == (Hostility)0)
481 {
482 if (!source.hostility.IsEmpty())
483 {
484 return source.hostility.ToEnum<Hostility>();
485 }
486 return Hostility.Enemy;
487 }
488 return base.c_originalHostility;
489 }
490 return Hostility.Ally;
491 }
492 }
493
494 public string IDPCCBodySet
495 {
496 get
497 {
498 if (source.idActor.Length <= 1)
499 {
500 return "female";
501 }
502 return source.idActor[1];
503 }
504 }
505
507
508 public new TraitChara trait
509 {
510 get
511 {
512 return base.trait as TraitChara;
513 }
514 set
515 {
516 base.trait = value;
517 }
518 }
519
520 public string NameBraced => GetName(NameStyle.Full);
521
522 public string NameTitled => (EClass.game.principal.permadeath ? "★" : "") + NameBraced;
523
524 public override string actorPrefab
525 {
526 get
527 {
528 if (IsPCC)
529 {
530 return "CharaActorPCC";
531 }
532 return "CharaActor";
533 }
534 }
535
536 public override int PrefIndex
537 {
538 get
539 {
540 if (sourceCard._tiles.Length != 0 || renderer.replacer != null)
541 {
542 if (base.dir != 1 && base.dir != 2)
543 {
544 return 0;
545 }
546 return 1;
547 }
548 return base.dir;
549 }
550 }
551
552 public override bool flipX
553 {
554 get
555 {
556 if (base.dir != 1)
557 {
558 return base.dir == 2;
559 }
560 return true;
561 }
562 }
563
564 public override string AliasMaterialOnCreate => race.material;
565
566 public override bool IsAliveInCurrentZone
567 {
568 get
569 {
570 if (!isDead)
571 {
572 return base.ExistsOnMap;
573 }
574 return false;
575 }
576 }
577
578 public override bool IsDeadOrSleeping
579 {
580 get
581 {
582 if (!isDead && conSleep == null && conSuspend == null)
583 {
584 return isFainted;
585 }
586 return true;
587 }
588 }
589
590 public override bool IsDisabled
591 {
592 get
593 {
594 if (!isDead && conSleep == null && !isFainted)
595 {
596 return isParalyzed;
597 }
598 return true;
599 }
600 }
601
602 public bool IsLevitating
603 {
604 get
605 {
606 if (ride != null)
607 {
608 return ride._isLevitating;
609 }
610 return _isLevitating;
611 }
612 }
613
614 public bool IsMarried
615 {
616 get
617 {
618 if (base.c_love != null)
619 {
620 return base.c_love.dateMarriage != 0;
621 }
622 return false;
623 }
624 }
625
626 public override bool IsMoving => idleTimer > 0f;
627
628 public override bool IsGlobal => global != null;
629
630 public override bool IsPC => this == EClass.player.chara;
631
632 public override bool IsPCParty
633 {
634 get
635 {
636 if (party != null)
637 {
638 return party.leader == EClass.pc;
639 }
640 return false;
641 }
642 }
643
644 public override bool IsMinion
645 {
646 get
647 {
648 if (master == null)
649 {
650 return base.c_uidMaster != 0;
651 }
652 return true;
653 }
654 }
655
656 public override bool IsPCPartyMinion
657 {
658 get
659 {
660 if (master != null)
661 {
662 if (!master.IsPCParty)
663 {
664 return master.IsPCPartyMinion;
665 }
666 return true;
667 }
668 return false;
669 }
670 }
671
672 public override bool IsPCFactionMinion
673 {
674 get
675 {
676 if (master != null)
677 {
678 if (!master.IsPCFaction)
679 {
681 }
682 return true;
683 }
684 return false;
685 }
686 }
687
688 public override bool IsPCFaction
689 {
690 get
691 {
692 if (EClass.pc != null)
693 {
694 return faction == EClass.pc.faction;
695 }
696 return false;
697 }
698 }
699
700 public override bool IsPCC => pccData != null;
701
702 public override bool isThing => false;
703
704 public override bool isChara => true;
705
706 public override bool HasHost => host != null;
707
708 public override bool isSynced
709 {
710 get
711 {
712 if (renderer == null || !renderer.isSynced)
713 {
714 if (host != null)
715 {
716 return host.isSynced;
717 }
718 return false;
719 }
720 return true;
721 }
722 }
723
724 public override bool IsMultisize => sourceCard.multisize;
725
726 public override int MaxHP => (int)Mathf.Clamp(((long)(base.END * 2 + base.STR + base.WIL / 2) * (long)Mathf.Min(base.LV, 25) / 25 + base.END + 10) * Evalue(60) / 100 * ((base.IsPCFactionOrMinion ? 100 : (100 + (int)base.rarity * 300)) + (IsPC ? (EClass.player.lastEmptyAlly * Evalue(1646)) : 0)) / 100, 1f, 1E+09f);
727
728 public override int WeightLimit => (int)Mathf.Clamp(((long)base.STR * 500L + base.END * 250 + Evalue(207) * 2000) * ((!HasElement(1411)) ? 1 : 5) + 45000, 1000f, 1.0737418E+09f);
729
730 public override int SelfWeight => ((bio.weight > 2000000) ? 2000000 : bio.weight) * 1000;
731
732 public int MaxSummon => Mathf.Max((int)Mathf.Sqrt(base.CHA), 1) + Evalue(1647) + ((!base.IsPCFactionOrMinion) ? ((int)base.rarity * 5) : 0);
733
735 {
736 get
737 {
738 if (base.c_idMainElement == 0)
739 {
740 return Element.Void;
741 }
742 return elements.GetElement(base.c_idMainElement);
743 }
744 }
745
746 public override int DV
747 {
748 get
749 {
750 if (IsPCFaction)
751 {
752 return WeaknessMod(elements.Value(64));
753 }
754 int num = base.LV;
755 if (num > 50)
756 {
757 num = 50 + (num - 50) / 10;
758 }
759 return WeaknessMod(num + elements.Value(64) * (100 + num + race.DV * 5) / 100);
760 int WeaknessMod(int a)
761 {
762 if (HasCondition<ConWeakness>())
763 {
764 if (a <= 0)
765 {
766 return a * 2;
767 }
768 return a / 2;
769 }
770 return a;
771 }
772 }
773 }
774
775 public override int PV
776 {
777 get
778 {
779 if (IsPCFaction)
780 {
781 return WeaknessMod(elements.Value(65));
782 }
783 int num = base.LV;
784 if (num > 50)
785 {
786 num = 50 + (num - 50) / 10;
787 }
788 return WeaknessMod(num + elements.Value(65) * (100 + num + race.PV * 5) / 100);
789 int WeaknessMod(int a)
790 {
791 if (HasCondition<ConWeakness>())
792 {
793 if (a <= 0)
794 {
795 return a * 2;
796 }
797 return a / 2;
798 }
799 return a;
800 }
801 }
802 }
803
804 public override SourcePref Pref
805 {
806 get
807 {
808 if (spriteReplacer != null)
809 {
811 {
812 spriteReplacer.data.tryFixPrefNotLoadedAtStart = true;
814 }
816 }
817 if (base.idSkin > 0)
818 {
819 switch (sourceCard.tiles.TryGet(base.idSkin))
820 {
821 case 2319:
822 case 2619:
823 case 2621:
824 case 2623:
825 case 2625:
827 case 2320:
828 case 2611:
829 case 2620:
830 case 2622:
831 case 2624:
832 case 2626:
833 case 2828:
835 }
836 }
838 }
839 }
840
841 public bool CanOpenDoor
842 {
843 get
844 {
845 if (base.INT < 5)
846 {
847 if (IsPCFaction)
848 {
849 return memberType == FactionMemberType.Default;
850 }
851 return false;
852 }
853 return true;
854 }
855 }
856
857 public Tactics tactics => _tactics ?? (_tactics = new Tactics(this));
858
860
862 {
863 get
864 {
865 if (!HasTag(CTAG.ride))
866 {
867 if (!HasTag(CTAG.noRide))
868 {
869 if (!race.tag.Contains("ride"))
870 {
871 if (!race.tag.Contains("noRide"))
872 {
873 return Ridability.Default;
874 }
875 return Ridability.BadRide;
876 }
877 return Ridability.GoodRide;
878 }
879 return Ridability.BadRide;
880 }
881 return Ridability.GoodRide;
882 }
883 }
884
886
887 public bool IsLocalChara
888 {
889 get
890 {
891 if (!IsGlobal && !base.isSubsetCard && homeZone == EClass._zone)
892 {
893 return !base.isSummon;
894 }
895 return false;
896 }
897 }
898
899 public bool IsIdle
900 {
901 get
902 {
903 if (!IsDeadOrSleeping)
904 {
905 return ai.Current.IsIdle;
906 }
907 return false;
908 }
909 }
910
911 public bool IsInCombat => ai is GoalCombat;
912
913 public bool IsAnimal
914 {
915 get
916 {
917 if (!race.IsAnimal)
918 {
919 return HasTag(CTAG.animal);
920 }
921 return true;
922 }
923 }
924
925 public bool IsHuman
926 {
927 get
928 {
929 if (!race.IsHuman)
930 {
931 return HasTag(CTAG.human);
932 }
933 return true;
934 }
935 }
936
937 public bool IsUndead
938 {
939 get
940 {
941 if (!race.IsUndead)
942 {
943 return HasTag(CTAG.undead);
944 }
945 return true;
946 }
947 }
948
949 public bool IsMachine
950 {
951 get
952 {
953 if (!race.IsMachine)
954 {
955 return HasTag(CTAG.machine);
956 }
957 return true;
958 }
959 }
960
961 public bool IsHorror
962 {
963 get
964 {
965 if (!race.IsHorror)
966 {
967 return HasTag(CTAG.horror);
968 }
969 return true;
970 }
971 }
972
973 public bool IsFish
974 {
975 get
976 {
977 if (!race.IsFish)
978 {
979 return HasTag(CTAG.fish);
980 }
981 return true;
982 }
983 }
984
985 public bool IsFairy
986 {
987 get
988 {
989 if (!race.IsFairy)
990 {
991 return HasTag(CTAG.fairy);
992 }
993 return true;
994 }
995 }
996
997 public bool IsGod
998 {
999 get
1000 {
1001 if (!race.IsGod)
1002 {
1003 return HasTag(CTAG.god);
1004 }
1005 return true;
1006 }
1007 }
1008
1009 public bool IsDragon
1010 {
1011 get
1012 {
1013 if (!race.IsDragon)
1014 {
1015 return HasTag(CTAG.dragon);
1016 }
1017 return true;
1018 }
1019 }
1020
1021 public bool IsPlant
1022 {
1023 get
1024 {
1025 if (!race.IsPlant)
1026 {
1027 return HasTag(CTAG.plant);
1028 }
1029 return true;
1030 }
1031 }
1032
1033 public bool IsCat
1034 {
1035 get
1036 {
1037 if (!(race.id == "cat") && !(race.id == "catsister"))
1038 {
1039 return race.id == "catgod";
1040 }
1041 return true;
1042 }
1043 }
1044
1046
1047 public bool HasNoGoal => ai.IsNoGoal;
1048
1049 public bool CanWitness
1050 {
1051 get
1052 {
1053 if (!IsHuman && !IsFairy && !IsGod)
1054 {
1055 return race.id == "mutant";
1056 }
1057 return true;
1058 }
1059 }
1060
1061 public bool IsHumanSpeak
1062 {
1063 get
1064 {
1065 if (!IsHuman && !race.tag.Contains("humanSpeak"))
1066 {
1067 return HasTag(CTAG.humanSpeak);
1068 }
1069 return true;
1070 }
1071 }
1072
1073 public bool IsMaid
1074 {
1075 get
1076 {
1077 if (EClass.Branch != null)
1078 {
1079 return EClass.Branch.uidMaid == base.uid;
1080 }
1081 return false;
1082 }
1083 }
1084
1085 public bool IsPrisoner => false;
1086
1087 public bool IsAdventurer
1088 {
1089 get
1090 {
1091 if (global != null && faction != EClass.pc.faction)
1092 {
1093 return IsPCC;
1094 }
1095 return false;
1096 }
1097 }
1098
1099 public bool IsEyth => faith.id == "eyth";
1100
1101 public bool IsWealthy
1102 {
1103 get
1104 {
1105 if (!source.works.Contains("Rich"))
1106 {
1107 return source.hobbies.Contains("Rich");
1108 }
1109 return true;
1110 }
1111 }
1112
1114
1115 public int MaxGeneSlot => race.geneCap - (HasElement(1237) ? 2 : 0) + Evalue(1242) + Evalue(1273) + (base.IsSlimeEvolvable ? (Evalue(1274) - 7) : 0);
1116
1117 public int GeneCostMTP
1118 {
1119 get
1120 {
1121 if (!IsPC)
1122 {
1123 return 100;
1124 }
1125 return 5;
1126 }
1127 }
1128
1130 {
1131 get
1132 {
1133 if (base.c_genes != null)
1134 {
1135 return base.c_genes.GetGeneSlot(this);
1136 }
1137 return 0;
1138 }
1139 }
1140
1141 public int Speed
1142 {
1143 get
1144 {
1145 if (dirtySpeed)
1146 {
1147 RefreshSpeed();
1148 }
1149 if (_Speed > 100000000)
1150 {
1151 return 100000000;
1152 }
1153 return (int)_Speed;
1154 }
1155 }
1156
1157 public bool IsMofuable
1158 {
1159 get
1160 {
1161 if (!race.tag.Contains("mofu"))
1162 {
1163 return HasElement(419);
1164 }
1165 return true;
1166 }
1167 }
1168
1170 {
1171 get
1172 {
1173 if (_baseWorkElements == null)
1174 {
1176 foreach (Hobby item in ListHobbies())
1177 {
1178 Build(item);
1179 }
1180 foreach (Hobby item2 in ListWorks())
1181 {
1182 Build(item2);
1183 }
1184 }
1185 return _baseWorkElements;
1186 void Build(Hobby h)
1187 {
1188 if (!h.source.elements.IsEmpty())
1189 {
1190 for (int i = 0; i < h.source.elements.Length; i += 2)
1191 {
1192 int ele = h.source.elements[i];
1193 int v = h.source.elements[i + 1];
1194 _baseWorkElements.ModBase(ele, v);
1195 }
1196 }
1197 }
1198 }
1199 }
1200
1201 public Stats hunger => Stats.Hunger.Set(_cints, 10, this);
1202
1203 public Stats burden => Stats.Burden.Set(_cints, 11, this);
1204
1205 public Stats stamina => Stats.Stamina.Set(_cints, 12, this);
1206
1208
1209 public Stats bladder => Stats.Bladder.Set(_cints, 14, this);
1210
1211 public Stats hygiene => Stats.Hygiene.Set(_cints, 15, this);
1212
1213 public Stats mana => Stats.Mana.Set(_cints, 16, this);
1214
1216
1217 public Stats SAN => Stats.SAN.Set(_cints, 18, this);
1218
1220 {
1221 get
1222 {
1223 if (base.rarity >= Rarity.Legendary)
1224 {
1225 return !IsPCFaction;
1226 }
1227 return false;
1228 }
1229 }
1230
1231 public override string ToString()
1232 {
1233 return base.Name + "(" + ai?.ToString() + ")" + pos?.ToString() + "/" + base.ExistsOnMap + "/" + isDead;
1234 }
1235
1236 public bool IsCriticallyWounded(bool includeRide = false)
1237 {
1238 if (host == null || includeRide)
1239 {
1240 if (Evalue(1421) <= 0)
1241 {
1242 return base.hp < MaxHP / 5;
1243 }
1244 return base.hp + mana.value < (MaxHP + mana.max) / 5;
1245 }
1246 return false;
1247 }
1248
1249 public bool HasHigherGround(Card c)
1250 {
1251 if (c == null)
1252 {
1253 return false;
1254 }
1255 float num = renderer.position.y - pos.Position(0).y + (_isLevitating ? 0.4f : 0f);
1256 float num2 = c.renderer.position.y - c.pos.Position(0).y + ((c.isChara && c.Chara._isLevitating) ? 0.4f : 0f);
1257 return num > num2 + 0.1f;
1258 }
1259
1260 public bool CanSeeSimple(Point p)
1261 {
1262 if (!p.IsValid || p.IsHidden)
1263 {
1264 return false;
1265 }
1266 if (IsPC)
1267 {
1268 if (fov != null)
1269 {
1270 return fov.lastPoints.ContainsKey(p.index);
1271 }
1272 return false;
1273 }
1274 return true;
1275 }
1276
1277 public bool CanSee(Card c)
1278 {
1279 if (c == this)
1280 {
1281 return true;
1282 }
1283 if (!c.pos.IsValid)
1284 {
1285 return false;
1286 }
1287 if (c.isChara)
1288 {
1290 {
1291 return true;
1292 }
1293 if (c.isHidden && c != this && !canSeeInvisible)
1294 {
1295 return false;
1296 }
1297 }
1298 if (IsPC)
1299 {
1300 if (fov != null)
1301 {
1302 return fov.lastPoints.ContainsKey(c.pos.index);
1303 }
1304 return false;
1305 }
1306 return true;
1307 }
1308
1309 public bool CanSeeLos(Card c, int dist = -1)
1310 {
1312 {
1313 return false;
1314 }
1315 return CanSeeLos(c.pos, dist);
1316 }
1317
1318 public bool CanSeeLos(Point p, int dist = -1)
1319 {
1320 if (dist == -1)
1321 {
1322 dist = pos.Distance(p);
1323 }
1324 if (dist > GetSightRadius())
1325 {
1326 return false;
1327 }
1328 if (IsPC)
1329 {
1330 if (fov != null)
1331 {
1332 return fov.lastPoints.ContainsKey(p.index);
1333 }
1334 return false;
1335 }
1336 if ((pos.IsBlocked || p.IsBlocked) && dist <= 1)
1337 {
1338 return true;
1339 }
1340 return Los.IsVisible(pos, p);
1341 }
1342
1343 public bool HasAccess(Card c)
1344 {
1345 return HasAccess(c.pos);
1346 }
1347
1348 public bool HasAccess(Point p)
1349 {
1350 if (!EClass._zone.IsPCFaction || p.cell.room == null || IsPC)
1351 {
1352 return true;
1353 }
1354 return p.cell.room.data.accessType switch
1355 {
1356 BaseArea.AccessType.Resident => memberType == FactionMemberType.Default,
1357 BaseArea.AccessType.Private => false,
1358 _ => true,
1359 };
1360 }
1361
1362 public bool CanSleep()
1363 {
1364 if (EClass._zone.events.GetEvent<ZoneEventQuest>() != null)
1365 {
1366 return false;
1367 }
1368 if (!EClass.debug.godMode && sleepiness.GetPhase() == 0)
1369 {
1370 return stamina.GetPhase() <= 1;
1371 }
1372 return true;
1373 }
1374
1375 protected override void OnSerializing()
1376 {
1377 if (enemy != null)
1378 {
1379 SetInt(55, enemy.uid);
1380 }
1381 _cints[0] = (int)_cbits1.Bits;
1382 List<BodySlot> slots = body.slots;
1383 rawSlots = new int[slots.Count];
1384 for (int i = 0; i < slots.Count; i++)
1385 {
1386 rawSlots[i] = slots[i].elementId;
1387 }
1388 }
1389
1390 protected override void OnDeserialized()
1391 {
1392 isCreated = true;
1393 _cbits1.Bits = (uint)_cints[0];
1394 InitStats(onDeserialize: true);
1395 body.SetOwner(this, deserialized: true);
1396 elements.ApplyElementMap(base.uid, SourceValueType.Chara, job.elementMap, base.DefaultLV);
1397 elements.ApplyElementMap(base.uid, SourceValueType.Chara, race.elementMap, base.DefaultLV);
1398 if (global != null && global.goal != null)
1399 {
1400 global.goal.SetOwner(this);
1401 }
1402 if (IsPCC)
1403 {
1404 pccData.state = (base.isCensored ? PCCState.Naked : PCCState.Normal);
1405 }
1406 if (tempElements != null)
1407 {
1408 tempElements.SetParent(this);
1409 }
1410 UpdateAngle();
1412 Refresh();
1413 if (source.tag.Contains("boss"))
1414 {
1415 bossText = true;
1416 }
1417 sharedCheckTurn = EClass.rnd(200);
1418 }
1419
1420 public override string GetName(NameStyle style, int num = -1)
1421 {
1422 if (mimicry != null && mimicry.Card != this)
1423 {
1424 return mimicry.GetName(style, num);
1425 }
1426 if (base.isBackerContent && EClass.core.config.backer.Show(base.c_idBacker))
1427 {
1428 if (id == "follower" && !IsGlobal)
1429 {
1430 return "_follower".lang(EClass.sources.backers.map[base.c_idBacker].Name, faith.Name);
1431 }
1432 return EClass.sources.backers.map[base.c_idBacker].Name;
1433 }
1434 string text = base.c_altName ?? source.GetName(this);
1435 if (HasCondition<ConTransmuteShadow>())
1436 {
1437 text = EClass.sources.charas.map["shade"].GetName(this);
1438 }
1439 text = text.Replace("#ele5", MainElement.source.GetAltname(3)).Replace("#ele4", MainElement.source.GetAltname(2)).Replace("#ele3", MainElement.source.GetAltname(1))
1440 .Replace("#ele2", MainElement.source.GetAltname(0))
1441 .Replace("#ele", MainElement.source.GetName().ToLower());
1442 if (base.c_bossType == BossType.Evolved)
1443 {
1444 text = "_evolved".lang(text.ToTitleCase(wholeText: true));
1445 }
1446 trait.SetName(ref text);
1447 if (text.Length > 0 && char.IsLower(text[0]))
1448 {
1449 if (base.rarity >= Rarity.Legendary)
1450 {
1451 text = text.ToTitleCase();
1452 }
1453 else if (num != 0)
1454 {
1455 text = text.AddArticle();
1456 }
1457 }
1458 if (style == NameStyle.Simple)
1459 {
1460 return text;
1461 }
1462 int num2 = ((base.rarity == Rarity.Mythical) ? 3 : ((base.rarity >= Rarity.Mythical) ? 2 : ((base.rarity >= Rarity.Legendary) ? 2 : ((!_alias.IsEmpty()) ? 1 : (-1)))));
1463 if (trait is TraitAdventurer)
1464 {
1465 num2 = 1;
1466 }
1467 text = ((Aka.IsEmpty() || !(Aka != text)) ? text.Bracket(num2) : (num2 switch
1468 {
1469 -1 => "_aka",
1470 1 => "_aka3",
1471 _ => "_aka2",
1472 }).lang((num2 == -1) ? Aka : Aka.ToTitleCase(wholeText: true), text.Bracket(num2)));
1473 string text2 = (base.isSale ? "forSale".lang(Lang._currency(GetPrice(CurrencyType.Money, sell: true, PriceType.PlayerShop), "money")) : "");
1474 return text + text2;
1475 }
1476
1477 public override void ChangeRarity(Rarity r)
1478 {
1479 if (r != base.rarity)
1480 {
1481 base.rarity = r;
1482 if (renderer != null && renderer.isSynced)
1483 {
1485 }
1486 base.hp = MaxHP;
1487 }
1488 }
1489
1491 {
1492 _faction = null;
1493 faction = f;
1495 return this;
1496 }
1497
1499 {
1500 homeZone = zone;
1501 SetGlobal();
1502 return this;
1503 }
1504
1506 {
1507 Hostility hostility = (base.c_originalHostility = h);
1508 this.hostility = hostility;
1509 return this;
1510 }
1511
1512 public void OnBanish()
1513 {
1514 if (!IsGlobal)
1515 {
1516 return;
1517 }
1518 memberType = FactionMemberType.Default;
1519 foreach (Thing item in things.List((Thing a) => a.HasTag(CTAG.godArtifact)).ToList())
1520 {
1522 }
1523 UniqueData uniqueData = base.c_uniqueData;
1524 if (uniqueData != null)
1525 {
1526 Debug.Log(uniqueData.uidZone + "/" + EClass.game.spatials.map.ContainsKey(uniqueData.uidZone) + "/" + uniqueData.x + "/" + uniqueData.y);
1527 }
1528 if (uniqueData != null && EClass.game.spatials.map.ContainsKey(uniqueData.uidZone))
1529 {
1530 MoveHome(EClass.game.spatials.map[uniqueData.uidZone] as Zone, uniqueData.x, uniqueData.y);
1531 return;
1532 }
1533 Zone z = EClass.game.spatials.Find("somewhere");
1534 if (trait is TraitAdventurer)
1535 {
1536 z = (from zone in EClass.world.region.ListTowns()
1537 where zone != EClass._zone
1538 select zone).RandomItem();
1539 SetHomeZone(z);
1540 }
1541 MoveZone(z, ZoneTransition.EnterState.RandomVisit);
1542 }
1543
1544 public Chara SetGlobal(Zone _home, int x, int z)
1545 {
1546 SetGlobal();
1547 homeZone = _home;
1548 _home.AddCard(this, x, z);
1549 global.transition = new ZoneTransition
1550 {
1551 state = ZoneTransition.EnterState.Exact,
1552 x = x,
1553 z = z
1554 };
1555 orgPos = new Point(x, z);
1556 return this;
1557 }
1558
1560 {
1561 if (!IsGlobal)
1562 {
1564 global = new GlobalData();
1565 base.isSubsetCard = false;
1566 enemy = null;
1567 base.c_uidMaster = 0;
1568 }
1569 return this;
1570 }
1571
1572 public void RemoveGlobal()
1573 {
1574 if (IsGlobal)
1575 {
1576 global = null;
1578 }
1579 }
1580
1581 public override void OnBeforeCreate()
1582 {
1583 if (source.job == "*r")
1584 {
1585 base.c_idJob = EClass.sources.jobs.rows.Where((SourceJob.Row j) => j.playable < 4).RandomItem().id;
1586 }
1587 if (bp.idJob != null)
1588 {
1589 base.c_idJob = bp.idJob;
1590 }
1591 if (bp.idRace != null)
1592 {
1593 base.c_idRace = bp.idRace;
1594 }
1595 }
1596
1597 public override void OnCreate(int genLv)
1598 {
1599 if (source.tag.Contains("boss"))
1600 {
1601 bossText = true;
1602 }
1603 int num = ((bp.lv != -999) ? bp.lv : base.LV);
1604 if (trait.AdvType == TraitChara.Adv_Type.Adv || trait.AdvType == TraitChara.Adv_Type.Adv_Fairy)
1605 {
1606 if (ListAdvRace.Count == 0)
1607 {
1608 ListAdvRace = EClass.sources.races.rows.Where((SourceRace.Row a) => a.playable <= 1 && a.id != "fairy").ToList();
1609 ListAdvJob = EClass.sources.jobs.rows.Where((SourceJob.Row a) => a.playable <= 4).ToList();
1610 }
1611 if (trait.AdvType == TraitChara.Adv_Type.Adv)
1612 {
1613 base.c_idRace = ListAdvRace.RandomItem().id;
1614 }
1615 base.c_idJob = ListAdvJob.RandomItem().id;
1616 _race = null;
1617 _job = null;
1618 num = 10 + EClass.rnd(40);
1619 }
1620 bio = new Biography();
1621 bio.Generate(this);
1622 if (source.idActor.Length != 0 && source.idActor[0] == "pcc" && pccData == null)
1623 {
1624 pccData = PCCData.Create(IDPCCBodySet);
1625 if (source.idActor.Length > 2)
1626 {
1627 pccData.SetPart("body", IDPCCBodySet, source.idActor[2]);
1628 }
1629 else
1630 {
1631 pccData.Randomize(IDPCCBodySet);
1632 }
1633 }
1634 if (source.mainElement.Length != 0)
1635 {
1636 int _genLv = Mathf.Min(genLv, 100);
1637 List<Tuple<string, int, int>> list = new List<Tuple<string, int, int>>();
1638 string[] mainElement = source.mainElement;
1639 for (int num2 = 0; num2 < mainElement.Length; num2++)
1640 {
1641 string[] array = mainElement[num2].Split('/');
1642 SourceElement.Row row = EClass.sources.elements.alias["ele" + array[0]];
1643 int num3 = source.LV * row.eleP / 100;
1644 if (list.Count == 0 || num3 < _genLv || array[0] == bp.idEle)
1645 {
1646 list.Add(new Tuple<string, int, int>(array[0], (array.Length > 1) ? int.Parse(array[1]) : 0, num3));
1647 }
1648 }
1649 Tuple<string, int, int> tuple = list.RandomItemWeighted((Tuple<string, int, int> a) => 10000 / Mathf.Max(100 + (_genLv - a.Item3) * 25, 1));
1650 if (!bp.idEle.IsEmpty())
1651 {
1652 tuple = list.Where((Tuple<string, int, int> a) => a.Item1 == bp.idEle || "ele" + a.Item1 == bp.idEle).FirstOrDefault() ?? tuple;
1653 }
1654 SetMainElement(tuple.Item1, (tuple.Item2 == 0) ? 10 : tuple.Item2, elemental: true);
1655 if (list.Count >= 2)
1656 {
1657 num = tuple.Item3 + base.LV - source.LV;
1658 }
1659 }
1660 if (trait.UseRandomName)
1661 {
1662 base.c_altName = NameGen.getRandomName();
1663 }
1665 {
1666 _alias = AliasGen.GetRandomAlias();
1667 }
1668 happiness = EClass.rnd(100);
1669 contribution = EClass.rnd(100);
1670 RerollHobby();
1671 _idTimeTable = ((EClass.rnd(5) == 0) ? 1 : 0);
1672 ApplyRace();
1673 ApplyJob();
1674 ChangeMaterial(source.defMat.IsEmpty(race.material), ignoreFixedMaterial: true);
1675 if (num != source.LV)
1676 {
1677 SetLv(num);
1678 }
1679 if (base.LV > 5 && race.id == "mutant")
1680 {
1681 for (int num4 = 0; num4 < Mathf.Min(1 + base.LV / 5, 20); num4++)
1682 {
1683 SetFeat(1644, num4 + 1);
1684 }
1685 }
1686 switch (id)
1687 {
1688 case "putty_mech_b":
1689 case "putty_mech":
1690 case "robot":
1691 SetFeat(1248, 1 + EClass.rnd(5));
1692 break;
1693 case "shojo":
1694 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
1695 {
1696 SetFeat(1432);
1697 }
1698 break;
1699 }
1700 InitStats();
1701 body.SetOwner(this);
1703 if (race.EQ.Length != 0 || !source.equip.IsEmpty())
1704 {
1705 TryRestock(onCreate: true);
1706 }
1707 switch (id)
1708 {
1709 case "dodo":
1710 base.idSkin = EClass.rnd(4);
1711 break;
1712 case "putty_snow":
1713 if (EClass.rnd(100) == 0 || EClass.debug.enable)
1714 {
1715 base.idSkin = EClass.rnd(4);
1716 }
1717 break;
1718 case "snail":
1719 base.idSkin = 5;
1720 break;
1721 case "olderyoungersister":
1722 base.idSkin = 1;
1723 break;
1724 case "sister_undead":
1725 case "dog":
1726 case "cat":
1727 base.idSkin = EClass.rnd(sourceCard.tiles.Length);
1728 if (id == "sister_undead" && EClass.rnd(10) == 0)
1729 {
1731 if (row2 != null && (!EClass.player.doneBackers.Contains(row2.id) || EClass.core.config.test.ignoreBackerDestoryFlag))
1732 {
1733 ApplyBacker(row2.id);
1734 }
1735 }
1736 break;
1737 case "baby":
1738 case "ika":
1739 SetFeat(1232, 3);
1740 break;
1741 }
1742 if (HasTag(CTAG.random_color))
1743 {
1744 DyeRandom();
1745 }
1746 SetAI(new NoGoal());
1747 if (!source.faith.IsEmpty())
1748 {
1749 SetFaith(source.faith);
1750 }
1751 else if (EClass.game.activeZone != null && EClass.game.activeZone.id == "foxtown")
1752 {
1754 }
1755 else if (EClass.game.activeZone != null && EClass.game.activeZone.id == "foxtown_nefu")
1756 {
1758 }
1759 else
1760 {
1761 SetFaith(EClass.game.religions.GetRandomReligion(onlyJoinable: true, EClass.rnd(10) == 0));
1762 }
1763 _affinity = 0;
1764 interest = 100;
1767 Refresh();
1768 stamina.value = stamina.max;
1769 mana.value = mana.max;
1770 isCreated = true;
1771 }
1772
1774 {
1776 {
1777 SetLv(base.LV + EClass._zone.DangerLvBoost);
1779 TryRestock(onCreate: true);
1780 }
1781 return this;
1782 }
1783
1784 public void SetFaith(string id)
1785 {
1787 }
1788
1789 public void SetFaith(Religion r)
1790 {
1791 faith = r;
1793 }
1794
1795 public void HealAll()
1796 {
1797 Cure(CureType.HealComplete);
1798 base.hp = MaxHP;
1799 mana.value = mana.max;
1800 stamina.value = stamina.max;
1801 Refresh();
1802 }
1803
1804 public void Refresh(bool calledRecursive = false)
1805 {
1806 if (source == null)
1807 {
1808 Debug.LogError("source is null");
1809 SetSource();
1810 }
1811 if (ride != null && ride.source != null)
1812 {
1813 ride.Refresh(calledRecursive: true);
1814 }
1815 hasTelepathy = false;
1816 isWet = false;
1817 _isLevitating = HasElement(401) || (ride != null && ride._isLevitating);
1819 isWeakToSunlight = HasElement(1251) && !HasElement(431);
1820 base.isHidden = HasElement(415);
1821 isAstralBody = HasElement(1430);
1822 foreach (Condition condition in conditions)
1823 {
1824 condition.OnRefresh();
1825 }
1826 if (isWet)
1827 {
1828 base.isHidden = false;
1829 }
1831 SetDirtySpeed();
1832 if (host != null && !calledRecursive && host.source != null)
1833 {
1834 host.Refresh(calledRecursive: true);
1835 }
1836 }
1837
1838 public bool TryFuse(float chance = 1f)
1839 {
1840 if (chance < EClass.rndf(1f))
1841 {
1842 return false;
1843 }
1844 List<Chara> list = ListFussableCharas(3);
1845 if (list.Count < 7)
1846 {
1847 return false;
1848 }
1849 Say("fuse", this);
1850 string text = "marshmallow_king";
1851 string text2 = "fusion";
1852 switch (id)
1853 {
1854 case "imotoroid":
1855 text = "imotomaton";
1856 text2 = "fusion2";
1857 break;
1858 case "shojo":
1859 text = "shojomaton";
1860 text2 = "fusion2";
1861 break;
1862 case "sister_cat":
1863 text = "sister_catmaton";
1864 text2 = "fusion2";
1865 break;
1866 case "younglady":
1867 text = "youngladymaton";
1868 text2 = "fusion2";
1869 break;
1870 }
1871 Chara chara = EClass._zone.SpawnMob(text, pos);
1872 chara.SetHostility(hostility);
1873 list.Shuffle();
1874 int num = 0;
1875 foreach (Chara item in list)
1876 {
1877 if (!text2.IsEmpty())
1878 {
1879 item.Talk(text2);
1880 }
1881 Effect.Get<EffectIRenderer>("throw_fuse").Play(item, item, item.pos, pos);
1882 item.Destroy();
1883 num++;
1884 if (num >= 7)
1885 {
1886 break;
1887 }
1888 }
1889 Destroy();
1890 chara.PlayAnime(AnimeID.FallSky);
1891 chara.pos.PlaySound("fuse");
1892 chara.pos.PlayEffect("vanish");
1893 return true;
1894 }
1895
1896 public bool IsFusable(Chara c)
1897 {
1898 if (c == this)
1899 {
1900 return false;
1901 }
1902 if (c.id != id)
1903 {
1904 return false;
1905 }
1906 if (c.IsPCFactionOrMinion || base.IsPCFactionOrMinion)
1907 {
1908 return false;
1909 }
1910 if (c.c_bossType != BossType.none || base.c_bossType != BossType.none)
1911 {
1912 return false;
1913 }
1915 {
1916 return false;
1917 }
1918 return true;
1919 }
1920
1921 public List<Chara> ListFussableCharas(int radius = 2)
1922 {
1923 return pos.ListCharasInRadius(this, radius, (Chara c) => IsFusable(c));
1924 }
1925
1927 {
1928 if (EClass._zone.IsRegion)
1929 {
1930 return false;
1931 }
1933 {
1934 return false;
1935 }
1936 if (corruption >= 100)
1937 {
1938 return false;
1939 }
1940 if (con != DuplicateCondition.Water && con != DuplicateCondition.Quantum && (HasCondition<ConPoison>() || HasCondition<ConConfuse>() || HasCondition<ConDim>() || HasCondition<ConParalyze>() || HasCondition<ConSleep>() || HasCondition<ConBurning>() || HasCondition<ConFreeze>() || HasCondition<ConMiasma>()))
1941 {
1942 return false;
1943 }
1944 switch (con)
1945 {
1946 case DuplicateCondition.Scarab:
1948 {
1949 return false;
1950 }
1951 break;
1952 case DuplicateCondition.SpiderEgg:
1953 if (pos.cell.light > 0 || pos.IsSunLit)
1954 {
1955 return false;
1956 }
1957 break;
1958 }
1959 return true;
1960 }
1961
1962 public Chara TryDuplicate(DuplicateCondition con = DuplicateCondition.Default, Point dest = null, bool inheritHostility = false)
1963 {
1964 if (dest == null)
1965 {
1966 dest = pos;
1967 }
1968 dest = dest.GetRandomPoint(2, requireLos: false, allowChara: false, allowBlocked: false, 200);
1969 if (dest == null || dest.Equals(pos) || !dest.IsValid || !CanDuplicate(con))
1970 {
1971 Say("split_fail", this);
1972 return null;
1973 }
1974 Chara chara = Duplicate();
1975 EClass._zone.AddCard(chara, dest);
1976 if (inheritHostility)
1977 {
1978 chara.SetHostility(hostility);
1979 }
1980 Say("split", this);
1981 return chara;
1982 }
1983
1985 {
1986 Chara chara = CharaGen.Create(id);
1987 chara.mana.value = mana.value;
1988 chara.stamina.value = stamina.value;
1989 foreach (KeyValuePair<int, Element> item in elements.dict)
1990 {
1991 if (item.Key != 1275)
1992 {
1993 Element orCreateElement = chara.elements.GetOrCreateElement(item.Key);
1994 orCreateElement.vBase = item.Value.ValueWithoutLink - orCreateElement.vSource;
1995 }
1996 }
1997 chara.SetFaith(faith);
1998 chara.bio = IO.DeepCopy(bio);
1999 chara.LV = base.LV;
2000 chara.c_daysWithGod = base.c_daysWithGod;
2001 chara.RefreshFaithElement();
2002 chara.hp = (int)Mathf.Clamp((float)chara.MaxHP * ((float)base.hp / (float)MaxHP) * 0.99f, 0f, chara.MaxHP);
2003 chara.isCopy = true;
2004 chara.isScaled = base.isScaled;
2005 chara.c_altName = base.c_altName;
2006 chara._alias = _alias;
2007 if (pccData != null)
2008 {
2009 chara.pccData = IO.DeepCopy(pccData);
2010 }
2011 if (HaveFur())
2012 {
2013 chara.c_fur = -1;
2014 }
2015 return chara;
2016 }
2017
2018 public int GetBurden(Card t = null, int num = -1)
2019 {
2020 int num2 = (base.ChildrenWeight + ((t != null) ? ((num == -1) ? t.ChildrenAndSelfWeight : (t.SelfWeight * num)) : 0)) * 100 / WeightLimit;
2021 if (num2 < 0)
2022 {
2023 num2 = 1000;
2024 }
2026 {
2027 num2 = 0;
2028 }
2029 int num3 = ((num2 >= 100) ? ((num2 - 100) / 10 + 1) : 0);
2030 if (num3 > 9)
2031 {
2032 num3 = 9;
2033 }
2034 return num3;
2035 }
2036
2037 public void CalcBurden()
2038 {
2039 int num = base.ChildrenWeight * 100 / Mathf.Max(1, WeightLimit);
2040 if (num < 0)
2041 {
2042 num = 1000;
2043 }
2045 {
2046 num = 0;
2047 }
2048 burden.Set(num);
2049 SetDirtySpeed();
2050 }
2051
2052 public void Stumble(int mtp = 100)
2053 {
2054 bool flag = EClass._map.FindThing((Thing t) => t.IsInstalled && t.pos.Equals(EClass.pc.pos) && t.trait is TraitStairsUp) != null;
2055 Say(flag ? "dmgBurdenStairs" : "dmgBurdenFallDown", this);
2056 long num = MaxHP;
2057 if (Evalue(1421) > 0)
2058 {
2059 num = mana.max;
2060 }
2061 long num2 = (num * (base.ChildrenWeight * 100 / WeightLimit) / (flag ? 100 : 200) + 1) * mtp / 100;
2062 if (base.hp <= 0)
2063 {
2064 num2 *= 2;
2065 }
2066 DamageHP(num2, flag ? AttackSource.BurdenStairs : AttackSource.BurdenFallDown);
2067 }
2068
2069 public void SetDirtySpeed()
2070 {
2071 dirtySpeed = true;
2072 if (host != null)
2073 {
2075 }
2076 }
2077
2078 public void RefreshSpeed(Element.BonusInfo info = null)
2079 {
2080 if (currentZone != EClass._zone)
2081 {
2082 dirtySpeed = true;
2083 return;
2084 }
2085 if (ride != null && !ride.IsDeadOrSleeping)
2086 {
2088 _Speed = ride._Speed;
2089 info?.AddText("rideSpeed".lang(_Speed.ToString() ?? ""));
2090 }
2091 else if (host != null)
2092 {
2093 if (host.ride == this)
2094 {
2095 _Speed = Evalue(79);
2096 int a = Evalue(1423);
2097 int num = ((!HasElement(495)) ? 1 : 3);
2098 int value = 100 + (int)_Speed * ((Ridability != Ridability.BadRide) ? 1 : 5) * Mathf.Max(a, 1) / num - base.STR - host.EvalueRiding() * 2 - ((Ridability == Ridability.GoodRide) ? 50 : 0);
2099 _Speed = _Speed * 100 / Mathf.Clamp(value, 100, 1000);
2100 }
2101 else
2102 {
2103 _Speed = (Evalue(79) + host.Evalue(79)) / 2;
2104 }
2105 }
2106 else
2107 {
2108 _Speed = Evalue(79) + Evalue(407) / 2;
2109 }
2110 if (body.GetSlot(37, onlyEmpty: false)?.thing != null && HasElement(1209) && !HasElement(419))
2111 {
2112 _Speed -= 25L;
2113 info?.AddText(-25L, EClass.sources.elements.map[1209].GetName());
2114 }
2115 if (parasite != null)
2116 {
2117 long speed = _Speed;
2118 int num2 = ((!HasElement(495)) ? 1 : 3);
2119 _Speed = _Speed * 100 / Mathf.Clamp(120 + parasite.LV * 2 / num2 - base.STR - Evalue(227) * 2, 100, 1000);
2120 info?.AddText(_Speed - speed, "parasiteSpeed".lang());
2121 }
2122 if (_Speed < elements.ValueWithoutLink(79) / 3)
2123 {
2125 info?.AddText("minSpeed".lang((elements.ValueWithoutLink(79) / 3).ToString() ?? ""));
2126 }
2127 int num3 = 100;
2128 if (EClass._zone.map != null && (EClass._zone.IsUnderwater || (base.Cell.IsTopWaterAndNoSnow && !base.Cell.isFloating)))
2129 {
2130 int num4 = Evalue(200);
2131 int num5 = Evalue(1252);
2132 num3 = 50 + Mathf.Clamp((int)Mathf.Sqrt(num4) * 5 - EClass._zone.DangerLv / 50, (num5 > 0) ? 50 : ((base.IsPowerful || IsMultisize) ? 40 : 0), 50) + Mathf.Clamp((int)Mathf.Sqrt(num4), 0, 25);
2133 if (info != null && num3 != 100)
2134 {
2135 info.AddFix(num3 - 100, EClass.sources.elements.map[200].GetName().ToTitleCase());
2136 }
2137 if (num5 > 0)
2138 {
2139 num3 += num5 * 20;
2140 info?.AddFix(num5 * 20, EClass.sources.elements.map[1252].GetName().ToTitleCase());
2141 }
2142 }
2143 if (IsPCFaction)
2144 {
2145 switch (burden.GetPhase())
2146 {
2147 case 1:
2148 num3 -= 10;
2149 info?.AddFix(-10, burden.GetPhaseStr());
2150 break;
2151 case 2:
2152 num3 -= 20;
2153 info?.AddFix(-20, burden.GetPhaseStr());
2154 break;
2155 case 3:
2156 num3 -= 30;
2157 info?.AddFix(-30, burden.GetPhaseStr());
2158 break;
2159 case 4:
2160 num3 -= (IsPC ? 50 : 100);
2161 info?.AddFix(IsPC ? (-50) : (-100), burden.GetPhaseStr());
2162 break;
2163 }
2164 if (IsPC)
2165 {
2166 switch (stamina.GetPhase())
2167 {
2168 case 1:
2169 num3 -= 10;
2170 info?.AddFix(-10, stamina.GetPhaseStr());
2171 break;
2172 case 0:
2173 num3 -= 20;
2174 info?.AddFix(-20, stamina.GetPhaseStr());
2175 break;
2176 }
2177 switch (sleepiness.GetPhase())
2178 {
2179 case 2:
2180 num3 -= 10;
2181 info?.AddFix(-10, sleepiness.GetPhaseStr());
2182 break;
2183 case 3:
2184 num3 -= 20;
2185 info?.AddFix(-20, sleepiness.GetPhaseStr());
2186 break;
2187 }
2188 switch (hunger.GetPhase())
2189 {
2190 case 3:
2191 case 4:
2192 num3 -= 10;
2193 info?.AddFix(-10, hunger.GetPhaseStr());
2194 break;
2195 case 5:
2196 num3 -= 30;
2197 info?.AddFix(-30, hunger.GetPhaseStr());
2198 break;
2199 }
2200 num3 += EClass.player.lastEmptyAlly * Evalue(1646);
2201 info?.AddFix(EClass.player.lastEmptyAlly * Evalue(1646), EClass.sources.elements.map[1646].GetName());
2202 }
2204 {
2205 num3 += EClass.player.lastEmptyAlly * 10 - 10;
2206 info?.AddFix(EClass.player.lastEmptyAlly * 10 - 10, "exceedParty".lang());
2207 }
2208 }
2209 else if (base.LV >= 1000 && !EClass.game.principal.disableVoidBlessing && !base.IsPCFactionOrMinion)
2210 {
2211 num3 += EClass.curve((base.LV - 900) / 100 * 10, 500, 100);
2212 info?.AddFix(EClass.curve((base.LV - 900) / 100 * 10, 500, 100), "enemySpeedBuff".lang());
2213 }
2214 if (HasCondition<ConGravity>())
2215 {
2216 num3 -= 30;
2217 info?.AddFix(-30, GetCondition<ConGravity>().Name);
2218 }
2219 if (_Speed < 10)
2220 {
2221 _Speed = 10L;
2222 }
2223 _Speed = _Speed * num3 / 100;
2224 if (_Speed < 10)
2225 {
2226 _Speed = 10L;
2227 info?.AddText("minSpeed".lang(10.ToString() ?? ""));
2228 }
2229 dirtySpeed = false;
2230 }
2231
2233 {
2234 int num = base.END;
2235 int num2 = 0;
2236 foreach (Element value in elements.dict.Values)
2237 {
2238 if (value.source.category == "skill")
2239 {
2240 num = ((!IsPC) ? (num + Mathf.Max(value.ValueWithoutLink, 0)) : (num + Mathf.Max(value.vBase, 0)));
2241 }
2242 }
2243 num2 = EClass.curve(num, 30, 10, 60);
2244 if (num2 < 10)
2245 {
2246 num2 = 10;
2247 }
2248 _maxStamina = num2 + 15;
2249 }
2250
2251 public override void ApplyEditorTags(EditorTag tag)
2252 {
2253 switch (tag)
2254 {
2255 case EditorTag.HostilityNeutral:
2256 {
2257 Hostility hostility = (base.c_originalHostility = Hostility.Neutral);
2258 this.hostility = hostility;
2259 break;
2260 }
2261 case EditorTag.HostilityEnemy:
2262 {
2263 Hostility hostility = (base.c_originalHostility = Hostility.Enemy);
2264 this.hostility = hostility;
2265 break;
2266 }
2267 case EditorTag.HostilityFriend:
2268 {
2269 Hostility hostility = (base.c_originalHostility = Hostility.Friend);
2270 this.hostility = hostility;
2271 break;
2272 }
2273 case EditorTag.Male:
2274 bio.SetGender(2);
2275 base.c_idPortrait = Portrait.GetRandomPortrait(2, GetIdPortraitCat());
2276 break;
2277 case EditorTag.Female:
2278 bio.SetGender(1);
2279 base.c_idPortrait = Portrait.GetRandomPortrait(1, GetIdPortraitCat());
2280 break;
2281 case EditorTag.baby:
2282 SetFeat(1232);
2283 break;
2284 }
2285 base.ApplyEditorTags(tag);
2286 }
2287
2288 public override void SetSource()
2289 {
2290 source = EClass.sources.charas.map.TryGetValue(id);
2291 if (source == null)
2292 {
2293 Debug.LogWarning("Chara " + id + " not found");
2294 id = "chicken";
2295 source = EClass.sources.charas.map[id];
2296 }
2297 path.walker = this;
2298 }
2299
2300 public void SetMainElement(string id, int v = 0, bool elemental = false)
2301 {
2302 if (!id.StartsWith("ele"))
2303 {
2304 id = "ele" + id;
2305 }
2306 SetMainElement(EClass.sources.elements.alias[id].id, v, elemental);
2307 }
2308
2309 public void SetMainElement(int id, int v = 0, bool elemental = false)
2310 {
2311 if (base.c_idMainElement != 0)
2312 {
2313 SetElements(base.c_idMainElement, remove: true);
2314 base.c_idMainElement = 0;
2315 }
2316 if (id != 0)
2317 {
2318 _ = EClass.sources.elements.map[id];
2319 SetElements(id, remove: false);
2320 base.c_idMainElement = id;
2321 if (elemental)
2322 {
2323 base.isElemental = true;
2324 _colorInt = 0;
2325 Color colorSprite = EClass.setting.elements[MainElement.source.alias].colorSprite;
2326 base.c_lightColor = (byte)Mathf.Clamp(colorSprite.r * 3f, 1f, 31f) * 1024 + (byte)Mathf.Clamp(colorSprite.g * 3f, 1f, 31f) * 32 + (byte)Mathf.Clamp(colorSprite.b * 3f, 1f, 31f);
2327 }
2328 _ability = null;
2329 }
2330 void SetElements(int idEle, bool remove)
2331 {
2332 elements.SetBase(idEle, (!remove) ? ((v == 0) ? 10 : v) : 0);
2333 elements.ModBase(EClass.sources.elements.alias[EClass.sources.elements.map[idEle].aliasRef].id, remove ? (-20) : 20);
2334 switch (idEle)
2335 {
2336 case 910:
2337 elements.ModBase(951, remove ? 10 : (-10));
2338 break;
2339 case 911:
2340 elements.ModBase(950, remove ? 10 : (-10));
2341 break;
2342 case 912:
2343 elements.ModBase(953, remove ? 10 : (-10));
2344 break;
2345 case 913:
2346 elements.ModBase(952, remove ? 10 : (-10));
2347 break;
2348 case 916:
2349 elements.ModBase(960, remove ? 10 : (-10));
2350 break;
2351 case 919:
2352 elements.ModBase(956, remove ? 10 : (-10));
2353 break;
2354 case 925:
2355 elements.ModBase(962, remove ? 10 : (-10));
2356 break;
2357 case 922:
2358 elements.ModBase(965, remove ? 10 : (-10));
2359 break;
2360 case 921:
2361 elements.ModBase(971, remove ? 10 : (-10));
2362 break;
2363 case 926:
2364 elements.ModBase(961, remove ? 10 : (-10));
2365 break;
2366 case 914:
2367 case 915:
2368 case 917:
2369 case 918:
2370 case 920:
2371 case 923:
2372 case 924:
2373 break;
2374 }
2375 }
2376 }
2377
2378 public void ApplyJob(bool remove = false)
2379 {
2380 elements.ApplyElementMap(base.uid, SourceValueType.Chara, job.elementMap, base.DefaultLV, remove, applyFeat: true);
2381 if (IsPCC)
2382 {
2383 EClass.game.uniforms.Apply(pccData, job.id, base.IsMale, canUseOtherGender: true);
2384 }
2385 }
2386
2387 public void ChangeJob(string idNew)
2388 {
2389 ApplyJob(remove: true);
2390 base.c_idJob = idNew;
2391 _job = null;
2392 ApplyJob();
2393 if (IsPCC)
2394 {
2395 PCC.Get(pccData).Build();
2396 }
2397 }
2398
2399 private int ParseBodySlot(string s)
2400 {
2401 return s switch
2402 {
2403 "é ­" => 30,
2404 "首" => 31,
2405 "体" => 32,
2406 "背" => 33,
2407 "手" => 35,
2408 "指" => 36,
2409 "è…•" => 34,
2410 "è…°" => 37,
2411 "è¶³" => 39,
2412 _ => -1,
2413 };
2414 }
2415
2416 public void AddRandomBodyPart(bool msg = false)
2417 {
2418 int ele = new int[9] { 30, 31, 33, 35, 35, 36, 34, 37, 39 }.RandomItem();
2419 body.AddBodyPart(ele);
2420 if (msg)
2421 {
2422 Say("gain_bodyparts", this, Element.Get(ele).GetName().ToLower());
2423 PlaySound("offering");
2424 }
2425 }
2426
2427 public void RemoveLastBodyPart(bool msg = false)
2428 {
2429 if (body.slots.Count != 0)
2430 {
2431 BodySlot bodySlot = body.slots.LastItem();
2432 body.RemoveBodyPartAt(body.slots.Count - 1);
2433 if (msg)
2434 {
2435 Say("lose_bodyparts", this, Element.Get(bodySlot.elementId).GetName().ToLower());
2436 PlaySound("offering");
2437 }
2438 }
2439 }
2440
2441 public void ResetBody()
2442 {
2443 for (int num = body.slots.Count - 1; num >= 0; num--)
2444 {
2445 BodySlot bodySlot = body.slots[num];
2446 if (bodySlot.elementId == 45 || bodySlot.elementId == 40)
2447 {
2448 return;
2449 }
2450 body.RemoveBodyPart(num);
2451 }
2452 string[] array = race.figure.Split('|');
2453 foreach (string s in array)
2454 {
2455 int num2 = ParseBodySlot(s);
2456 if (num2 != -1)
2457 {
2458 body.AddBodyPart(num2);
2459 }
2460 }
2462 }
2463
2464 public void ApplyRace(bool remove = false)
2465 {
2466 string[] array = race.figure.Split('|');
2467 foreach (string s in array)
2468 {
2469 int num = ParseBodySlot(s);
2470 if (num != -1)
2471 {
2472 if (remove)
2473 {
2474 body.RemoveBodyPart(num);
2475 }
2476 else
2477 {
2478 body.AddBodyPart(num);
2479 }
2480 }
2481 }
2483 elements.ApplyElementMap(base.uid, SourceValueType.Chara, race.elementMap, base.DefaultLV, remove, applyFeat: true);
2484 if (remove)
2485 {
2486 if (HasElement(1423))
2487 {
2488 SetFeat(1423, 0);
2489 }
2490 return;
2491 }
2492 bool flag = id == "chara" || id == "player";
2493 if (race.id == "bike" && id != "bike_cub")
2494 {
2495 SetFeat(1423, flag ? 10 : (1 + EClass.rnd(10)));
2496 }
2497 if (id == "moa")
2498 {
2499 SetFeat(1423, flag ? 7 : (1 + EClass.rnd(7)));
2500 }
2501 if (race.id == "horse" && EClass.rnd(5) == 0)
2502 {
2503 SetFeat(1423, flag ? 5 : (1 + EClass.rnd(5)));
2504 }
2505 }
2506
2507 public void ChangeRace(string idNew)
2508 {
2509 ApplyRace(remove: true);
2510 base.c_idRace = idNew;
2511 _race = null;
2512 ApplyRace();
2513 ChangeMaterial(source.defMat.IsEmpty(race.material));
2514 }
2515
2516 public void MakePartyMemeber()
2517 {
2518 _MakeAlly();
2519 EClass.pc.party.AddMemeber(this);
2520 }
2521
2522 public void MakeAlly(bool msg = true)
2523 {
2524 if (IsLocalChara && !base.IsUnique)
2525 {
2526 Debug.Log("Creating Replacement NPC for:" + this);
2528 }
2529 _MakeAlly();
2530 if (msg)
2531 {
2532 EClass.pc.Say("hire", this);
2533 EClass.Sound.Play("good");
2534 }
2535 EClass.pc.party.AddMemeber(this);
2536 if (EClass._zone.IsTown)
2537 {
2539 }
2540 }
2541
2542 public void _MakeAlly()
2543 {
2544 if (EClass.pc.homeBranch != null)
2545 {
2547 }
2548 else
2549 {
2550 SetGlobal();
2552 }
2553 Hostility hostility = (base.c_originalHostility = Hostility.Ally);
2554 this.hostility = hostility;
2555 orgPos = null;
2556 base.c_summonDuration = 0;
2557 base.isSummon = false;
2558 UnmakeMinion();
2559 SetInt(32);
2560 Refresh();
2561 }
2562
2563 public bool CanBeTempAlly(Chara c)
2564 {
2565 if (IsPCFaction || IsGlobal || IsMinion || IsMultisize || EClass._zone.CountMinions(c) > c.MaxSummon || base.rarity >= Rarity.Legendary)
2566 {
2567 return false;
2568 }
2569 if (HasElement(1222))
2570 {
2571 return false;
2572 }
2573 return true;
2574 }
2575
2576 public void Banish(Chara owner)
2577 {
2578 owner?.Say("summon_vanish", this);
2579 pos.PlayEffect("vanish");
2580 pos.PlaySound("vanish");
2581 pos.PlayEffect("teleport");
2582 Destroy();
2583 }
2584
2585 public void MakeMinion(Chara _master, MinionType type = MinionType.Default)
2586 {
2587 UnmakeMinion();
2588 Hostility hostility = (base.c_originalHostility = (_master.IsPCFaction ? Hostility.Ally : _master.hostility));
2589 this.hostility = hostility;
2590 base.c_uidMaster = _master.uid;
2591 base.c_minionType = type;
2592 master = _master;
2593 Refresh();
2594 }
2595
2596 public void UnmakeMinion()
2597 {
2598 base.c_uidMaster = 0;
2599 master = null;
2600 enemy = null;
2601 foreach (Chara chara in EClass._map.charas)
2602 {
2603 if (chara.enemy == this)
2604 {
2605 chara.SetEnemy();
2606 chara.ai.Cancel();
2607 }
2608 }
2609 ai.Cancel();
2610 Refresh();
2611 }
2612
2613 public void BanishAllMinions()
2614 {
2615 List<Chara> list = new List<Chara>();
2616 foreach (Chara chara in EClass._map.charas)
2617 {
2618 if (chara.IsMinion && chara.master == this)
2619 {
2620 list.Add(chara);
2621 }
2622 }
2623 foreach (Chara item in list)
2624 {
2625 item.Banish(this);
2626 }
2627 }
2628
2629 public bool HasMinion(string id)
2630 {
2631 foreach (Chara chara in EClass._map.charas)
2632 {
2633 if (chara.c_uidMaster == base.uid)
2634 {
2635 return true;
2636 }
2637 }
2638 return false;
2639 }
2640
2641 public void SetSummon(int duration)
2642 {
2643 base.c_summonDuration = duration;
2644 base.isSummon = true;
2645 }
2646
2648 {
2649 if (IsMinion)
2650 {
2651 master = EClass._map.FindChara(base.c_uidMaster);
2652 }
2653 return master;
2654 }
2655
2656 public bool IsEscorted()
2657 {
2658 if (!IsPCPartyMinion)
2659 {
2660 return false;
2661 }
2662 foreach (Quest item in EClass.game.quests.list)
2663 {
2664 if (item is QuestEscort questEscort && questEscort.uidChara == base.uid)
2665 {
2666 return true;
2667 }
2668 }
2669 return false;
2670 }
2671
2672 public bool CanDestroyPath()
2673 {
2674 if (!IsMultisize)
2675 {
2676 if (base.rarity >= Rarity.Superior && !base.IsPCFactionOrMinion && ai is GoalCombat)
2677 {
2678 return !EClass._zone.IsPCFaction;
2679 }
2680 return false;
2681 }
2682 return true;
2683 }
2684
2685 public bool CanMoveTo(Point p, bool allowDestroyPath = true)
2686 {
2687 if (!p.IsValid)
2688 {
2689 return false;
2690 }
2691 int num = ((p.z >= pos.z) ? ((p.x > pos.x) ? 1 : ((p.z > pos.z) ? 2 : 3)) : 0);
2692 if (allowDestroyPath && CanDestroyPath())
2693 {
2694 if (!p.IsInBounds)
2695 {
2696 return false;
2697 }
2698 }
2699 else
2700 {
2702 {
2703 return false;
2704 }
2705 if (p.x != pos.x && p.z != pos.z)
2706 {
2707 Cell[,] cells = EClass._map.cells;
2708 int x = p.x;
2709 int z = pos.z;
2710 int num2 = ((z >= pos.z) ? ((x > pos.x) ? 1 : ((z > pos.z) ? 2 : 3)) : 0);
2711 if (cells[pos.x, pos.z].weights[num2] == 0)
2712 {
2713 return false;
2714 }
2715 if (cells[x, z].blocked && (!IsAstralBody || cells[x, z].IsSky || EClass._zone.IsRegion))
2716 {
2717 return false;
2718 }
2719 num2 = ((z >= p.z) ? ((x > p.x) ? 1 : ((z > p.z) ? 2 : 3)) : 0);
2720 if (cells[p.x, p.z].weights[num2] == 0)
2721 {
2722 return false;
2723 }
2724 x = pos.x;
2725 z = p.z;
2726 num2 = ((z >= pos.z) ? ((x > pos.x) ? 1 : ((z > pos.z) ? 2 : 3)) : 0);
2727 if (cells[pos.x, pos.z].weights[num2] == 0)
2728 {
2729 return false;
2730 }
2731 if (cells[x, z].blocked && (!IsAstralBody || cells[x, z].IsSky || EClass._zone.IsRegion))
2732 {
2733 return false;
2734 }
2735 num2 = ((z >= p.z) ? ((x > p.x) ? 1 : ((z > p.z) ? 2 : 3)) : 0);
2736 if (cells[p.x, p.z].weights[num2] == 0)
2737 {
2738 return false;
2739 }
2740 }
2741 }
2742 if (IsPC)
2743 {
2744 if (IsEnemyOnPath(p))
2745 {
2746 return false;
2747 }
2748 }
2749 else if (p.HasChara && !IsMultisize && !CanReplace(p.FirstChara))
2750 {
2751 return false;
2752 }
2753 return true;
2754 }
2755
2756 public bool IsEnemyOnPath(Point p, bool cancelAI = true)
2757 {
2758 if (!currentZone.IsRegion && p.IsValid)
2759 {
2760 CellDetail detail = p.detail;
2761 if (detail != null && detail.charas.Count > 0)
2762 {
2763 foreach (Chara chara in p.detail.charas)
2764 {
2765 if (chara.mimicry == null && (chara.IsHostile(this) || chara.IsHostile() || !chara.trait.CanBePushed))
2766 {
2767 if (cancelAI && EClass.pc.ai is GoalManualMove)
2768 {
2769 EClass.pc.ai.Cancel();
2770 }
2771 return true;
2772 }
2773 }
2774 }
2775 }
2776 return false;
2777 }
2778
2779 public bool CanInteractTo(Card c)
2780 {
2781 return CanInteractTo(c.pos);
2782 }
2783
2784 public bool CanInteractTo(Point p)
2785 {
2786 if (!p.IsValid)
2787 {
2788 return false;
2789 }
2790 if (EClass._map.cells[p.x, p.z].blocked)
2791 {
2792 return true;
2793 }
2794 if (!IsMultisize)
2795 {
2796 int num = ((p.z >= pos.z) ? ((p.x > pos.x) ? 1 : ((p.z > pos.z) ? 2 : 3)) : 0);
2797 if (EClass._map.cells[pos.x, pos.z].weights[num] == 0)
2798 {
2799 return false;
2800 }
2801 if (p.x != pos.x && p.z != pos.z)
2802 {
2803 Cell[,] cells = EClass._map.cells;
2804 int x = p.x;
2805 int z = pos.z;
2806 int num2 = ((z >= pos.z) ? ((x > pos.x) ? 1 : ((z > pos.z) ? 2 : 3)) : 0);
2807 if (cells[pos.x, pos.z].weights[num2] == 0)
2808 {
2809 return false;
2810 }
2811 num2 = ((z >= p.z) ? ((x > p.x) ? 1 : ((z > p.z) ? 2 : 3)) : 0);
2812 if (cells[p.x, p.z].weights[num2] == 0)
2813 {
2814 return false;
2815 }
2816 x = pos.x;
2817 z = p.z;
2818 num2 = ((z >= pos.z) ? ((x > pos.x) ? 1 : ((z > pos.z) ? 2 : 3)) : 0);
2819 if (cells[pos.x, pos.z].weights[num2] == 0)
2820 {
2821 return false;
2822 }
2823 num2 = ((z >= p.z) ? ((x > p.x) ? 1 : ((z > p.z) ? 2 : 3)) : 0);
2824 if (cells[p.x, p.z].weights[num2] == 0)
2825 {
2826 return false;
2827 }
2828 }
2829 }
2830 return true;
2831 }
2832
2833 public Point GetFirstStep(Point newPoint, PathManager.MoveType moveType = PathManager.MoveType.Default)
2834 {
2835 return PathManager.Instance.GetFirstStep(pos, newPoint, this, IsPC ? 40 : 10, (!IsMultisize) ? moveType : PathManager.MoveType.Default);
2836 }
2837
2838 public bool MoveRandom()
2839 {
2840 Point randomNeighbor = pos.GetRandomNeighbor();
2841 if (!randomNeighbor.Equals(pos) && !randomNeighbor.HasChara && HasAccess(randomNeighbor))
2842 {
2843 if ((race.tag.Contains("water") || source.tag.Contains("water")) && pos.cell.IsTopWaterAndNoSnow && !randomNeighbor.IsDeepWater)
2844 {
2845 return false;
2846 }
2847 return TryMove(randomNeighbor) == MoveResult.Success;
2848 }
2849 return false;
2850 }
2851
2853 {
2854 List<Point> list = new List<Point>();
2855 pos.ForeachNeighbor(delegate(Point p)
2856 {
2857 list.Add(p.Copy());
2858 });
2859 list.Shuffle();
2860 foreach (Point item in list)
2861 {
2862 if (!item.Equals(pos) && !item.HasChara && TryMove(item) == MoveResult.Success)
2863 {
2864 return true;
2865 }
2866 }
2867 return false;
2868 }
2869
2870 public void MoveByForce(Point newPoint, Card c = null, bool checkWall = false)
2871 {
2872 if (!newPoint.sourceBlock.tileType.IsBlockPass && (!checkWall || (Dist(newPoint) <= 1 && CanMoveTo(newPoint, allowDestroyPath: false))) && _Move(newPoint, MoveType.Force) == MoveResult.Success && ai.Current.CancelWhenMoved)
2873 {
2874 ai.Current.TryCancel(c);
2875 }
2876 }
2877
2879 {
2880 if (p.Equals(pos))
2881 {
2882 return MoveResult.Success;
2883 }
2885 {
2886 return MoveResult.Fail;
2887 }
2888 bool flag = true;
2889 Point point = null;
2890 _sharedPos.Set(p);
2891 if (CanDestroyPath())
2892 {
2894 {
2895 return MoveResult.Success;
2896 }
2897 Debug.Log(CanMoveTo(pos));
2899 }
2900 int num = pos.Distance(p);
2901 PathProgress pathProgress = PathManager.Instance.RequestPathImmediate(pos, p, this, PathManager.MoveType.Default, num + 4, 1);
2902 if (pathProgress.HasPath && pathProgress.nodes.Count < num + 4)
2903 {
2904 PathFinderNode pathFinderNode = pathProgress.nodes[pathProgress.nodes.Count - 1];
2905 if (TryMove(new Point(pathFinderNode.X, pathFinderNode.Z)) == MoveResult.Success)
2906 {
2907 return MoveResult.Success;
2908 }
2909 }
2910 pathProgress = PathManager.Instance.RequestPathImmediate(pos, p, this, PathManager.MoveType.Combat, num + 4, 1);
2911 if (pathProgress.HasPath && pathProgress.nodes.Count < num + 4)
2912 {
2913 PathFinderNode pathFinderNode2 = pathProgress.nodes[pathProgress.nodes.Count - 1];
2914 if (TryMove(new Point(pathFinderNode2.X, pathFinderNode2.Z)) == MoveResult.Success)
2915 {
2916 return MoveResult.Success;
2917 }
2918 }
2919 pathProgress = PathManager.Instance.RequestPathImmediate(pos, p, this, PathManager.MoveType.Default, num + 25, 2);
2920 if (pathProgress.HasPath && pathProgress.nodes.Count < num + 25)
2921 {
2922 PathFinderNode pathFinderNode3 = pathProgress.nodes[pathProgress.nodes.Count - 1];
2923 if (TryMove(new Point(pathFinderNode3.X, pathFinderNode3.Z)) == MoveResult.Success)
2924 {
2925 return MoveResult.Success;
2926 }
2927 }
2928 pathProgress = PathManager.Instance.RequestPathImmediate(pos, p, this, PathManager.MoveType.Combat, num + 25, 2);
2929 if (pathProgress.HasPath && pathProgress.nodes.Count < num + 25)
2930 {
2931 PathFinderNode pathFinderNode4 = pathProgress.nodes[pathProgress.nodes.Count - 1];
2932 if (TryMove(new Point(pathFinderNode4.X, pathFinderNode4.Z)) == MoveResult.Success)
2933 {
2934 return MoveResult.Success;
2935 }
2936 }
2937 return MoveResult.Fail;
2938 }
2939
2940 public override MoveResult TryMove(Point newPoint, bool allowDestroyPath = true)
2941 {
2942 foreach (Condition condition in conditions)
2943 {
2944 if (!condition.TryMove(newPoint))
2945 {
2946 return MoveResult.Fail;
2947 }
2948 }
2949 if (base.isRestrained)
2950 {
2951 if (!IsPC)
2952 {
2953 return MoveResult.Fail;
2954 }
2955 base.isRestrained = false;
2956 }
2957 if (!CanMoveTo(newPoint, allowDestroyPath))
2958 {
2959 return MoveResult.Fail;
2960 }
2961 return _Move(newPoint);
2962 }
2963
2964 public override MoveResult _Move(Point newPoint, MoveType type = MoveType.Walk)
2965 {
2966 if (isDead)
2967 {
2968 return MoveResult.Fail;
2969 }
2970 if (IsPC)
2971 {
2972 float num = EClass.setting.defaultActPace;
2973 switch (burden.GetPhase())
2974 {
2975 case 3:
2976 num *= 1.5f;
2977 break;
2978 case 4:
2979 num *= 2f;
2980 break;
2981 }
2983 {
2984 int num2 = 30;
2985 if (!EClass.pc.HasElement(408))
2986 {
2988 {
2989 case Weather.Condition.Rain:
2990 num2 += 5;
2991 break;
2992 case Weather.Condition.RainHeavy:
2993 num2 += 10;
2994 num *= 1.5f;
2995 break;
2996 case Weather.Condition.Snow:
2997 num2 += 10;
2998 break;
2999 case Weather.Condition.SnowHeavy:
3000 num2 += 15;
3001 num *= 1.5f;
3002 break;
3003 }
3004 }
3005 if (newPoint.matFloor.id == 48)
3006 {
3007 num2 += 20;
3008 num *= 1.8f;
3009 }
3010 num2 = num2 * 100 / (100 + EClass.sqrt(EvalueMax(240, -20) * 10) + EvalueMax(407, -5) * 5);
3011 EClass.world.date.AdvanceMin(num2 * 6);
3012 EClass.player.lastZonePos = null;
3014 int num3 = base.hp;
3015 for (int i = 0; i < num2 * 4; i++)
3016 {
3017 EClass.pc.party.members.ForeachReverse(delegate(Chara m)
3018 {
3019 if (!m.isDead)
3020 {
3021 m.TickConditions();
3022 }
3023 });
3024 if (base.hp < MaxHP / 5 && base.hp < num3 && !EClass.player.regionMoveWarned)
3025 {
3026 EClass.player.regionMoveWarned = true;
3027 Msg.Say("regionAbortMove");
3028 EInput.Consume(consumeAxis: true);
3029 SetAI(new NoGoal());
3030 return MoveResult.Fail;
3031 }
3032 }
3033 if (newPoint.cell.CanSuffocate())
3034 {
3035 bool flag = HasElement(1252);
3036 if (!flag)
3037 {
3038 AddCondition<ConSuffocation>((Evalue(200) != 0) ? (2000 / (100 + EvalueMax(200, -5) * 10)) : 30, force: true);
3039 }
3040 int num4 = GetCondition<ConSuffocation>()?.GetPhase() ?? 0;
3041 if (num4 >= 2)
3042 {
3043 DamageHP(EClass.rndHalf(10 + MaxHP / 5), AttackSource.Condition);
3044 }
3045 if (!isDead && !HasElement(429))
3046 {
3047 ModExp(200, ((!flag) ? 1 : 10) + num4 * 12);
3048 }
3049 }
3050 EClass.player.regionMoveWarned = false;
3051 if (isDead)
3052 {
3053 return MoveResult.Fail;
3054 }
3055 }
3056 if (num > EClass.setting.defaultActPace * 3f)
3057 {
3058 num = EClass.setting.defaultActPace * 3f;
3059 }
3060 actTime = num;
3061 }
3062 if (IsPCFaction && EClass.rnd(5) == 0 && newPoint.cell.CanSuffocate())
3063 {
3064 int num5 = Mathf.Min(5 + EClass._zone.DangerLv / 10, 200);
3065 ModExp(200, EClass._zone.IsRegion ? 50 : num5);
3066 if (ride != null)
3067 {
3068 ride.ModExp(200, EClass._zone.IsRegion ? 50 : num5);
3069 }
3070 if (parasite != null)
3071 {
3072 parasite.ModExp(200, EClass._zone.IsRegion ? 50 : num5);
3073 }
3074 }
3075 Chara chara = ((ride == null) ? this : ride);
3076 if (!EClass._zone.IsRegion || chara.IsPC)
3077 {
3078 bool flag2 = (chara.isConfused && EClass.rnd(2) == 0) || (chara.isDrunk && EClass.rnd(IsIdle ? 2 : 8) == 0 && !chara.HasElement(1215));
3079 if (host != null && host.ride == this && ((host.isConfused && EClass.rnd(2) == 0) || (host.isDrunk && EClass.rnd(IsIdle ? 2 : 8) == 0 && !host.HasElement(1215))))
3080 {
3081 flag2 = true;
3082 }
3083 if (flag2 && !HasElement(493) && newPoint.Distance(pos) <= 1)
3084 {
3085 Point randomNeighbor = pos.GetRandomNeighbor();
3086 if (CanMoveTo(randomNeighbor, allowDestroyPath: false))
3087 {
3088 newPoint = randomNeighbor;
3089 if (isDrunk)
3090 {
3091 Talk("drunk");
3092 }
3093 }
3094 }
3095 }
3096 if (newPoint.x != pos.x || newPoint.z != pos.z)
3097 {
3098 LookAt(newPoint);
3099 }
3100 CellEffect effect = base.Cell.effect;
3101 if (effect != null && effect.id == 7)
3102 {
3103 CellEffect effect2 = base.Cell.effect;
3104 if (race.height < 500 && !race.tag.Contains("webfree") && !HasElement(493) && EClass.rnd(effect2.power + 25) > EClass.rnd(base.STR + base.DEX + 1))
3105 {
3106 Say("abWeb_caught", this);
3107 PlaySound("web");
3108 effect2.power = effect2.power * 3 / 4;
3109 renderer.PlayAnime(AnimeID.Shiver);
3110 return MoveResult.Fail;
3111 }
3112 Say("abWeb_pass", this);
3113 EClass._map.SetEffect(base.Cell.x, base.Cell.z);
3114 }
3115 if (IsPC)
3116 {
3117 EClass.player.renderExtraTime = 0f;
3118 if (EClass._zone.IsRegion)
3119 {
3121 }
3122 else if ((newPoint.x > pos.x && newPoint.z > pos.z) || (newPoint.x < pos.x && newPoint.z < pos.z))
3123 {
3124 EClass.player.renderExtraTime = actTime * EClass.setting.render.anime.diagonalSpeed;
3125 }
3126 }
3127 if (newPoint.HasChara)
3128 {
3129 foreach (Chara item in newPoint.ListCharas())
3130 {
3131 if (item.mimicry != null && item.IsHostile(this))
3132 {
3133 if (item.mimicry.ShouldRevealOnPush)
3134 {
3135 item.mimicry.Reveal(this, surprise: true);
3136 }
3137 return MoveResult.Event;
3138 }
3139 }
3140 }
3141 if (newPoint.cell.hasDoor)
3142 {
3143 foreach (Thing thing in pos.Things)
3144 {
3145 if (thing.trait is TraitDoor traitDoor && traitDoor.owner.c_lockLv > 0)
3146 {
3147 if (base.INT < 10)
3148 {
3149 return MoveResult.Fail;
3150 }
3151 traitDoor.TryOpenLock(this);
3152 return MoveResult.Door;
3153 }
3154 }
3155 }
3156 Cell cell = newPoint.cell;
3157 Cell cell2 = pos.cell;
3158 bool flag3 = cell.HasLiquid && !IsLevitating;
3159 bool hasBridge = cell.HasBridge;
3160 bool hasRamp = cell.HasRamp;
3161 bool flag4 = EClass._zone.IsSnowCovered && !cell.HasRoof && !cell.isClearSnow;
3162 TileRow tileRow = (hasRamp ? ((TileRow)cell.sourceBlock) : ((TileRow)(hasBridge ? cell.sourceBridge : cell.sourceFloor)));
3163 SourceMaterial.Row row = (hasRamp ? cell.matBlock : (hasBridge ? cell.matBridge : cell.matFloor));
3164 bool flag5 = cell.IsTopWater && !cell.isFloating;
3165 if (!EClass._zone.IsRegion)
3166 {
3167 if (cell.hasDoorBoat)
3168 {
3169 tileRow = FLOOR.sourceWood;
3170 row = MATERIAL.sourceOak;
3171 flag5 = false;
3172 }
3173 else if (flag4 && !tileRow.ignoreSnow)
3174 {
3175 if (tileRow.tileType.IsWater)
3176 {
3177 tileRow = FLOOR.sourceIce;
3178 row = MATERIAL.sourceIce;
3179 }
3180 else
3181 {
3182 tileRow = FLOOR.sourceSnow;
3183 row = MATERIAL.sourceSnow;
3184 }
3185 flag5 = false;
3186 }
3187 }
3188 if ((pos.sourceFloor.isBeach || cell2.IsSnowTile) && !pos.HasObj)
3189 {
3190 EClass._map.SetFoormark(pos, 1, (int)Util.GetAngle(pos.x - newPoint.x, pos.z - newPoint.z), cell2.IsSnowTile ? 312 : 304);
3191 }
3192 if (isSynced)
3193 {
3194 string text = ((flag3 || flag5) ? "water" : tileRow.soundFoot.IsEmpty(row.soundFoot.IsEmpty("default")));
3195 if (cell.obj != 0 && cell.sourceObj.tileType.IsPlayFootSound && !cell.matObj.soundFoot.IsEmpty())
3196 {
3197 text = cell.matObj.soundFoot;
3198 }
3199 if (IsPC)
3200 {
3201 foreach (Thing thing2 in newPoint.Things)
3202 {
3203 if (thing2.IsInstalled && (thing2.trait.IsChangeFloorHeight || thing2.Pref.Surface))
3204 {
3205 text = thing2.material.soundFoot;
3206 }
3207 }
3208 }
3209 if (!text.IsEmpty())
3210 {
3211 SoundManager.altLastData = IsPC;
3212 PlaySound("Footstep/" + text, IsPC ? 1f : 0.9f);
3213 }
3214 if (!flag5)
3215 {
3217 PCOrbit pcOrbit = EClass.screen.pcOrbit;
3218 bool flag6 = scene.actionMode.gameSpeed > 1f;
3219 scene.psFoot.transform.position = renderer.position + pcOrbit.footPos;
3220 scene.psFoot.startColor = row.matColor;
3221 scene.psFoot.Emit(pcOrbit.emitFoot * ((!flag6) ? 1 : 2));
3222 if (flag6 && IsPC)
3223 {
3224 scene.psSmoke.transform.position = renderer.position + pcOrbit.smokePos;
3225 scene.psSmoke.Emit(pcOrbit.emitSmoke);
3226 }
3227 }
3228 if (flag3 || flag5)
3229 {
3230 Effect.Get("ripple").Play(newPoint);
3231 }
3232 }
3233 lastPos.Set(pos);
3234 if (type != MoveType.Force)
3235 {
3236 if (newPoint.HasChara && ai.Current.PushChara)
3237 {
3238 TryPush(newPoint);
3239 }
3240 if (newPoint.HasChara && newPoint.Charas.Count == 1)
3241 {
3242 Chara chara2 = newPoint.Charas[0];
3243 if (CanReplace(chara2))
3244 {
3245 chara2.MoveByForce(lastPos, this);
3246 if (chara.IsPC)
3247 {
3248 Say("replace_pc", chara, chara2);
3249 }
3250 }
3251 }
3252 }
3253 if (cell.hasDoor)
3254 {
3255 foreach (Thing thing3 in newPoint.Things)
3256 {
3257 if (thing3.trait is TraitDoor traitDoor2)
3258 {
3259 traitDoor2.TryOpen(this);
3260 }
3261 }
3262 }
3263 EClass._zone.map.MoveCard(newPoint, this);
3264 SyncRide();
3266 {
3267 foreach (Chara member in EClass.pc.party.members)
3268 {
3269 if (member.isLeashed && !member.IsPC && member.host == null && !member.IsDisabled && !member.HasCondition<ConEntangle>() && !member.IsInCombat && member.Dist(EClass.pc) > 1)
3270 {
3271 member.TryMoveTowards(EClass.pc.pos);
3272 }
3273 }
3274 }
3276 {
3278 }
3279 if (IsPC)
3280 {
3281 PlaySound("Footstep/Extra/pcfootstep");
3282 if (pos.HasThing)
3283 {
3284 foreach (Card item2 in pos.ListCards())
3285 {
3286 if (!item2.isThing || item2.placeState != PlaceState.roaming || item2.ignoreAutoPick)
3287 {
3288 continue;
3289 }
3291 {
3293 ContainerFlag containerFlag = item2.category.GetRoot().id.ToEnum<ContainerFlag>();
3294 if (containerFlag == ContainerFlag.none)
3295 {
3296 containerFlag = ContainerFlag.other;
3297 }
3298 if ((dataPick.noRotten && item2.IsDecayed) || (dataPick.onlyRottable && item2.trait.Decay == 0))
3299 {
3300 continue;
3301 }
3302 if (dataPick.userFilter)
3303 {
3304 switch (dataPick.IsFilterPass(item2.GetName(NameStyle.Full, 1)))
3305 {
3306 case Window.SaveData.FilterResult.PassWithoutFurtherTest:
3307 Pick(item2.Thing);
3308 continue;
3309 case Window.SaveData.FilterResult.Block:
3310 continue;
3311 }
3312 }
3313 if (dataPick.advDistribution)
3314 {
3315 foreach (int cat in dataPick.cats)
3316 {
3317 if (item2.category.uid == cat)
3318 {
3319 Pick(item2.Thing);
3320 }
3321 }
3322 }
3323 else if (!dataPick.flag.HasFlag(containerFlag))
3324 {
3325 Pick(item2.Thing);
3326 }
3327 }
3328 else
3329 {
3330 Pick(item2.Thing);
3331 }
3332 }
3333 }
3334 if (EClass._zone.IsRegion)
3335 {
3337 if (cell3?.zone != null && !cell3.zone.HiddenInRegionMap && (!(cell3.zone is Zone_Field) || cell3.zone.children.Count > 0 || cell3.zone.IsPCFaction))
3338 {
3339 Msg.Say((!cell3.zone.source.GetText("textFlavor").IsEmpty()) ? cell3.zone.source.GetText("textFlavor") : (cell3.zone.ShowDangerLv ? "seeZoneDanger" : "seeZone"), cell3.zone.Name, cell3.zone.DangerLv.ToString() ?? "");
3340 }
3341 if (pos.matFloor.alias == "snow" && EClass.rnd(3) == 0)
3342 {
3344 Msg.Say(Lang.GetList("walk_snow").RandomItem());
3345 }
3346 else if (EClass.world.weather.CurrentCondition == Weather.Condition.RainHeavy && EClass.rnd(3) == 0)
3347 {
3349 Msg.Say(Lang.GetList("walk_storm").RandomItem());
3350 }
3351 }
3352 ActWait.Search(this);
3353 }
3354 if (IsPCC)
3355 {
3356 int num6 = Mathf.Abs(cell2.topHeight - cell.topHeight);
3357 if ((num6 >= 3 && lastPos.sourceBlock.tileType.slopeHeight == 0 && newPoint.sourceBlock.tileType.slopeHeight == 0) || cell2.hasDoorBoat || cell.hasDoorBoat)
3358 {
3359 renderer.PlayAnime((cell2.topHeight >= cell.topHeight) ? AnimeID.JumpDown : ((num6 >= 6) ? AnimeID.Jump : AnimeID.JumpSmall));
3360 }
3361 else
3362 {
3363 float surfaceHeight = cell2.GetSurfaceHeight();
3364 float surfaceHeight2 = cell.GetSurfaceHeight();
3365 num6 = (int)Mathf.Abs((surfaceHeight - surfaceHeight2) * 100f);
3366 if (num6 >= 15)
3367 {
3368 renderer.PlayAnime((surfaceHeight >= surfaceHeight2) ? AnimeID.JumpDown : ((num6 >= 40) ? AnimeID.Jump : AnimeID.JumpSmall));
3369 }
3370 }
3371 }
3372 if (IsPC)
3373 {
3374 if (renderer.anime == null && renderer.replacer != null && renderer.replacer.pccData == null)
3375 {
3377 }
3379 {
3380 if (!FLOOR.IsTatami(pos.cell.sourceSurface.id) && pos.cell.room == null)
3381 {
3382 EClass.player.flags.isShoesOff = false;
3383 EClass.pc.Say("shoes_on", EClass.pc);
3384 EClass.pc.SetPCCState(PCCState.Normal);
3385 }
3386 }
3387 else if (FLOOR.IsTatami(pos.cell.sourceSurface.id) && pos.cell.room != null)
3388 {
3389 EClass.player.flags.isShoesOff = true;
3390 EClass.pc.Say("shoes_off", EClass.pc);
3391 EClass.pc.SetPCCState(PCCState.ShoesOff);
3392 }
3393 }
3394 bool flag7 = flag5 || EClass._zone.IsUnderwater;
3395 if (wasInWater != flag7)
3396 {
3397 wasInWater = flag7;
3398 RefreshSpeed();
3399 }
3400 lastPos.Things.ForeachReverse(delegate(Thing t)
3401 {
3402 t.trait.OnSteppedOut(this);
3403 });
3404 if (!IsPC)
3405 {
3406 pos.Things.ForeachReverse(delegate(Thing t)
3407 {
3408 t.trait.OnStepped(this);
3409 });
3410 }
3411 if (CanDestroyPath())
3412 {
3414 }
3415 if (!isDead)
3416 {
3417 if (Evalue(492) > 0 && EClass.rnd(10000 / (80 + Evalue(492) * 2)) == 0)
3418 {
3419 AddExp(Mathf.Clamp((int)Mathf.Sqrt(base.ExpToNext / 100), 1, 1000));
3420 }
3421 if (pos.IsBlocked && EClass.rnd(IsPC ? 2 : 20) == 0)
3422 {
3423 stamina.Mod(-1);
3424 }
3425 }
3426 hasMovedThisTurn = true;
3427 return MoveResult.Success;
3428 }
3429
3430 public void DestroyPath(Point pos)
3431 {
3432 bool broke = false;
3433 pos.ForeachMultiSize(base.W, base.H, delegate(Point _p, bool main)
3434 {
3435 if (_p.IsValid)
3436 {
3437 if (_p.HasBlock)
3438 {
3439 EClass._map.MineBlock(_p, recoverBlock: false, this);
3440 if (_p.HasObj)
3441 {
3442 EClass._map.MineObj(_p, null, this);
3443 }
3444 broke = true;
3445 }
3446 if (_p.HasObj && _p.IsBlocked)
3447 {
3448 EClass._map.MineObj(_p, null, this);
3449 broke = true;
3450 }
3451 _p.Things.ForeachReverse(delegate(Thing t)
3452 {
3453 if (t.IsInstalled && (t.trait.IsBlockPath || t.trait.IsDoor))
3454 {
3455 if (t.isNPCProperty && t.trait.CanBeDestroyed)
3456 {
3457 t.Destroy();
3458 }
3459 else if (!t.IsUnique && !t.trait.CanBeDestroyed)
3460 {
3461 t.SetPlaceState(PlaceState.roaming);
3462 }
3463 }
3464 });
3465 }
3466 });
3467 if (broke)
3468 {
3469 Msg.Say("stomp");
3470 Shaker.ShakeCam("stomp");
3471 }
3472 }
3473
3474 public void TryPush(Point point)
3475 {
3476 List<Chara> list = point.ListCharas();
3477 if (list.Count == 0)
3478 {
3479 return;
3480 }
3481 list.Copy().ForeachReverse(delegate(Chara c)
3482 {
3483 if ((trait is TraitSnitch && c.IsPCFactionOrMinion) || (!c.ai.IsMoveAI && !c.IsPC && c.trait.CanBePushed && c != this && !c.noMove && (!EClass._zone.IsRegion || c.IsPCFactionOrMinion)))
3484 {
3485 List<Point> list2 = new List<Point>();
3486 for (int i = point.x - 1; i <= point.x + 1; i++)
3487 {
3488 for (int j = point.z - 1; j <= point.z + 1; j++)
3489 {
3490 if (i != point.x || j != point.z)
3491 {
3492 Point point2 = new Point(i, j);
3493 if (point2.IsValid && !point2.HasChara && !point2.IsBlocked && !point2.cell.hasDoor && !point2.IsBlockByHeight(point))
3494 {
3495 list2.Add(point2);
3496 }
3497 }
3498 }
3499 }
3500 if (list2.Count > 0)
3501 {
3502 if (list2.Count > 1)
3503 {
3504 list2.ForeachReverse(delegate(Point p)
3505 {
3506 if (p.Equals(new Point(point.x + point.x - pos.x, point.z + point.z - pos.z)))
3507 {
3508 list2.Remove(p);
3509 }
3510 });
3511 }
3512 Point newPoint = list2.RandomItem();
3513 if (IsPC)
3514 {
3515 Say("displace", this, c);
3516 PlaySound("push");
3517 }
3518 else if (c.isSynced)
3519 {
3520 c.PlayEffect("push");
3521 }
3522 c.MoveByForce(newPoint, this, checkWall: true);
3523 if (!c.IsPC && c.trait is TraitRogue && EClass.rnd(3) == 0 && GetCurrency() > 20 && !HasElement(426))
3524 {
3525 int num = EClass.rndHalf(10 + Mathf.Min(GetCurrency() / 100, 1000));
3526 c.Talk("pushed");
3527 Say("pushed_money", this, c);
3528 ModCurrency(-num);
3529 c.ModCurrency(num);
3530 c.PlaySound("steal_money");
3531 }
3532 else if (IsPC && !c.IsPCParty && !c.IsUnique && c.IsHumanSpeak && EClass.rnd(5) == 0)
3533 {
3534 c.Talk("pushed");
3535 }
3536 }
3537 }
3538 });
3539 }
3540
3541 public bool CanReplace(Chara c)
3542 {
3543 if (c.IsMultisize || !c.trait.CanBePushed || c.isRestrained || c.noMove || IsHostile(c) || IsMinion || (EClass._zone.IsRegion && !c.IsPCFactionOrMinion))
3544 {
3545 return false;
3546 }
3547 if (IsPC)
3548 {
3549 return true;
3550 }
3551 if (c.IsPC || c.pos.Equals(EClass.pc.pos) || c.host != null)
3552 {
3553 return false;
3554 }
3555 if (!IsHostile(c))
3556 {
3557 if (c.c_uidMaster != 0 || c.isSummon || base.IsPowerful || IsEscorted())
3558 {
3559 return true;
3560 }
3561 if (DestDist < c.DestDist)
3562 {
3563 return true;
3564 }
3565 if (IsPCParty && !c.IsPCParty)
3566 {
3567 return true;
3568 }
3569 if (IsPCFaction && !c.IsPCParty)
3570 {
3571 return true;
3572 }
3573 }
3574 return false;
3575 }
3576
3577 public void MoveZone(string alias)
3578 {
3579 MoveZone(EClass.game.spatials.Find(alias));
3580 }
3581
3583 {
3584 MoveZone(z, new ZoneTransition
3585 {
3586 state = state
3587 });
3588 }
3589
3590 public void MoveZone(Zone z, ZoneTransition transition)
3591 {
3592 if (z == currentZone)
3593 {
3594 return;
3595 }
3596 if (EClass.game.IsSurvival && z.IsRegion)
3597 {
3598 z = EClass.pc.homeZone;
3599 transition = new ZoneTransition
3600 {
3601 state = ZoneTransition.EnterState.Return
3602 };
3603 }
3604 if (HasCondition<ConInvulnerable>())
3605 {
3606 RemoveCondition<ConInvulnerable>();
3607 }
3608 if (IsPC)
3609 {
3610 EClass.player.nextZone = z;
3611 if (IsInActiveZone && !EClass.player.simulatingZone)
3612 {
3613 TryDropCarryOnly();
3614 if (z.instance == null && currentZone.instance == null && !EClass.player.deathZoneMove && !EClass.pc.isDead && (z.IsPCFaction || z.WillAutoSave) && z.GetTopZone() != EClass._zone.GetTopZone())
3615 {
3616 if (EClass.player.returnInfo != null)
3617 {
3618 EClass.player.returnInfo.turns += 5;
3619 }
3621 {
3622 EClass.game.Save(isAutoSave: true);
3623 }
3624 }
3625 EClass.player.deathZoneMove = false;
3626 }
3627 currentZone.events.OnLeaveZone();
3628 if (currentZone.instance != null)
3629 {
3630 ZoneInstance instance = currentZone.instance;
3631 z = EClass.game.spatials.Find(instance.uidZone) ?? EClass.pc.homeZone;
3632 transition = new ZoneTransition
3633 {
3634 state = instance.ReturnState,
3635 x = instance.x,
3636 z = instance.z
3637 };
3638 instance.OnLeaveZone();
3639 Debug.Log(z);
3640 }
3641 EInput.Consume(consumeAxis: true);
3642 EClass.player.uidLastZone = currentZone.uid;
3644 {
3645 if (currentZone.IsRegion)
3646 {
3647 Msg.Say("enterZone", z.Name);
3648 }
3649 else
3650 {
3651 if (z.IsRegion)
3652 {
3653 Msg.Say("leaveZone", currentZone.Name);
3654 }
3655 else if (z.id != currentZone.id)
3656 {
3657 Msg.Say("enterZone", z.Name);
3658 }
3659 EClass.player.lastZonePos = pos.Copy();
3660 }
3661 EClass.player.lastTransition = transition;
3662 }
3663 foreach (Chara item in EClass._map.charas.Where((Chara c) => c.IsPCPartyMinion && c.master != EClass.pc).ToList())
3664 {
3666 }
3667 EClass.player.listCarryoverMap = EClass._map.charas.Where((Chara c) => c.c_uidMaster != 0 && c.FindMaster() == EClass.pc && c.c_minionType == MinionType.Default).ToList();
3668 if (!z.IsRegion && (z is Zone_Tent || currentZone is Zone_Tent))
3669 {
3670 foreach (Chara chara in EClass._map.charas)
3671 {
3672 if (chara.c_uidMaster == 0 && !chara.IsGlobal && !chara.isNPCProperty && (chara.id == "reaper" || chara.id == "messenger_death") && ((chara.enemy != null && chara.enemy.IsPCFactionOrMinion) || chara.Dist(EClass.pc) < 5))
3673 {
3674 EClass.player.listCarryoverMap.Add(chara);
3675 }
3676 }
3677 }
3678 foreach (Chara item2 in EClass.player.listCarryoverMap)
3679 {
3680 EClass._zone.RemoveCard(item2);
3681 }
3682 }
3683 if (party != null && party.leader == this)
3684 {
3685 foreach (Chara member in party.members)
3686 {
3687 if (member != this && !member.isDead && member.parent is Zone)
3688 {
3689 member.MoveZone(z);
3690 }
3691 }
3692 }
3693 if (global == null)
3694 {
3695 Debug.Log(base.Name);
3696 return;
3697 }
3698 transition.uidLastZone = currentZone?.uid ?? 0;
3699 global.transition = transition;
3700 if (z.IsActiveZone)
3701 {
3702 Point spawnPos = z.GetSpawnPos(this);
3703 global.transition = null;
3704 if (IsPC)
3705 {
3706 EClass.player.lastTransition = null;
3707 }
3708 z.AddCard(this, spawnPos);
3709 if (IsBranchMember())
3710 {
3712 }
3713 }
3714 else
3715 {
3716 z.AddCard(this);
3717 }
3718 }
3719
3720 public void MoveHome(string id, int x = -1, int z = -1)
3721 {
3722 MoveHome(EClass.game.world.FindZone(id), x, z);
3723 }
3724
3725 public void MoveHome(Zone zone, int x = -1, int z = -1)
3726 {
3727 if (isDead)
3728 {
3729 Revive();
3730 }
3731 else
3732 {
3733 Cure(CureType.Death);
3734 }
3735 CureCondition<ConSuspend>();
3736 if (IsPCParty)
3737 {
3739 }
3740 FactionBranch factionBranch = homeBranch;
3741 if (x == -1)
3742 {
3743 x = 50;
3744 }
3745 if (z == -1)
3746 {
3747 z = 50;
3748 }
3749 Point point = new Point(x, z);
3750 if (zone.IsActiveZone)
3751 {
3752 point = point.GetNearestPoint(allowBlock: false, allowChara: false);
3753 }
3754 zone.AddCard(this, point);
3755 SetHomeZone(zone);
3756 global.transition = new ZoneTransition
3757 {
3758 state = ZoneTransition.EnterState.Dead,
3759 x = point.x,
3760 z = point.z
3761 };
3762 orgPos = new Point(x, z);
3763 if (factionBranch != null)
3764 {
3765 RefreshWorkElements();
3766 factionBranch.policies.Validate();
3767 }
3768 }
3769
3770 public void FallFromZone()
3771 {
3772 Msg.Say("skyFall", EClass.pc, EClass._zone.Name);
3773 Zone zone = (EClass._zone.isExternalZone ? null : EClass._zone.GetTopZone().FindZone(EClass._zone.lv - 1));
3774 zone = zone ?? EClass.world.region;
3775 MoveZone(zone ?? EClass.world.region, new ZoneTransition
3776 {
3777 state = ZoneTransition.EnterState.Fall,
3778 x = pos.x,
3779 z = pos.z
3780 });
3781 }
3782
3783 public override void SetDir(int d)
3784 {
3785 base.dir = d;
3786 UpdateAngle();
3787 renderer.RefreshSprite();
3788 }
3789
3790 public override void Rotate(bool reverse = false)
3791 {
3792 if (renderer.hasActor)
3793 {
3794 base.dir = (base.dir + ((!reverse) ? 1 : (-1))).Clamp(0, 3, loop: true);
3795 }
3796 else
3797 {
3798 base.dir = ((base.dir == 0) ? 1 : 0);
3799 }
3800 UpdateAngle();
3801 renderer.RefreshSprite();
3802 }
3803
3804 public override void LookAt(Card c)
3805 {
3806 LookAt(c.pos);
3807 }
3808
3809 public override void LookAt(Point p)
3810 {
3811 angle = Util.GetAngle(p.x - pos.x, p.z - pos.z);
3812 if (EClass._zone.IsRegion)
3813 {
3814 if (angle > 100f && angle < 170f)
3815 {
3816 base.dir = 2;
3817 }
3818 else if (angle > 170f && angle < 190f)
3819 {
3820 base.dir = 0;
3821 }
3822 else if (angle > 190f || (angle < -10f && angle > -100f))
3823 {
3824 base.dir = 3;
3825 }
3826 else
3827 {
3828 base.dir = 1;
3829 }
3830 angle -= 45f;
3831 }
3832 else if (angle > 170f && angle < 235f)
3833 {
3834 base.dir = 0;
3835 }
3836 else if (angle > 80f && angle < 145f)
3837 {
3838 base.dir = 1;
3839 }
3840 else if (angle > -100f && angle < -35f)
3841 {
3842 base.dir = 3;
3843 }
3844 else if (angle > -10f && angle < 55f)
3845 {
3846 base.dir = 2;
3847 }
3848 renderer.RefreshSprite();
3849 }
3850
3851 public void UpdateAngle()
3852 {
3853 if (IsPCC)
3854 {
3855 if (base.dir == 0)
3856 {
3857 angle = 225f;
3858 }
3859 else if (base.dir == 1)
3860 {
3861 angle = 135f;
3862 }
3863 else if (base.dir == 2)
3864 {
3865 angle = 45f;
3866 }
3867 else if (base.dir == 3)
3868 {
3869 angle = -45f;
3870 }
3871 }
3872 else if (base.dir == 0)
3873 {
3874 angle = 165f;
3875 }
3876 else if (base.dir == 1)
3877 {
3878 angle = 300f;
3879 }
3880 else if (base.dir == 2)
3881 {
3882 angle = 0f;
3883 }
3884 else if (base.dir == 3)
3885 {
3886 angle = 120f;
3887 }
3888 }
3889
3890 public int GetCurrentDir()
3891 {
3892 Debug.Log(angle);
3893 if (!renderer.hasActor)
3894 {
3895 if (angle == 0f || angle == 45f || angle == 90f)
3896 {
3897 return 2;
3898 }
3899 if (angle == -135f || angle == 180f || angle == -90f)
3900 {
3901 return 1;
3902 }
3903 if (angle == 135f)
3904 {
3905 return 0;
3906 }
3907 return 3;
3908 }
3909 return renderer.actor.currentDir;
3910 }
3911
3912 public void UpdateSight()
3913 {
3914 int num = 4;
3915 for (int i = -num; i < num + 1; i++)
3916 {
3917 for (int j = -num; j < num + 1; j++)
3918 {
3919 shared.Set(pos.x + i, pos.z + j);
3920 if (shared.IsValid && !shared.cell.isSeen && i >= -1 && i <= 1 && j >= -1)
3921 {
3922 _ = 1;
3923 }
3924 }
3925 }
3926 }
3927
3928 public bool WillConsumeTurn()
3929 {
3930 for (int num = conditions.Count - 1; num >= 0; num--)
3931 {
3932 if (conditions[num].ConsumeTurn)
3933 {
3934 return true;
3935 }
3936 }
3937 return false;
3938 }
3939
3940 public void TickConditions()
3941 {
3942 if (_cooldowns != null)
3943 {
3944 TickCooldown();
3945 }
3946 turn++;
3947 consumeTurn = false;
3948 preventRegen = false;
3949 emoIcon = Emo2.none;
3950 if (base.isSummon)
3951 {
3952 base.c_summonDuration--;
3953 if (base.c_summonDuration <= 0)
3954 {
3955 Die();
3956 return;
3957 }
3958 }
3959 if (EClass.world.weather.IsRaining && !EClass._map.IsIndoor && !pos.cell.HasRoof)
3960 {
3961 AddCondition<ConWet>(20);
3962 }
3963 switch (turn % 50)
3964 {
3965 case 0:
3966 happiness = (hunger.value + stamina.value + depression.value + bladder.value + hygiene.value) / 5;
3967 break;
3968 case 1:
3969 if (!IsPC || !EClass.debug.godMode)
3970 {
3971 if (EClass.rnd(2) == 0 && !HasCondition<ConAwakening>())
3972 {
3973 sleepiness.Mod(1);
3974 }
3975 if (EClass.rnd(3) == 0)
3976 {
3977 hunger.Mod(1);
3978 }
3979 if (IsPC && (sleepiness.GetPhase() != 0 || stamina.GetPhase() <= 1))
3980 {
3981 Tutorial.Play("sleep");
3982 }
3983 }
3984 break;
3985 case 2:
3986 if (parasite != null)
3987 {
3988 ModExp(227, (int)((EClass._zone.IsRegion ? 5 : 40) + parasite.affinity.CurrentStage));
3989 }
3990 if (ride != null)
3991 {
3992 ModExp(226, (int)((EClass._zone.IsRegion ? 5 : 40) + ride.affinity.CurrentStage));
3993 }
3994 break;
3995 case 3:
3996 {
3997 int phase = hygiene.GetPhase();
3998 int num = 0;
3999 num = ((!IsPC) ? ((phase > 3) ? 50 : 0) : ((phase > 3) ? 50 : 0));
4000 if (num > EClass.rnd(100))
4001 {
4002 hygiene.Mod(-1);
4003 }
4004 break;
4005 }
4006 case 4:
4007 if (IsPC)
4008 {
4010 }
4011 break;
4012 case 5:
4013 case 30:
4014 if (isWeakToSunlight && pos.IsSunLit && !EClass.debug.godMode)
4015 {
4016 AddCondition<ConBurning>(1000, force: true);
4017 }
4018 break;
4019 case 10:
4020 if (HasElement(1250))
4021 {
4022 if (!HasCondition<ConVampire>())
4023 {
4024 AddCondition<ConVampire>();
4025 }
4026 if (!IsPC && !HasCooldown(8793))
4027 {
4028 bool flag = false;
4029 flag = ((!HasCondition<ConTransmuteBat>()) ? (!HasElement(431) && pos.IsSunLit) : (body.HasElement(431) || (EClass.world.date.IsNight && !pos.IsSunLit)));
4030 if (flag && base.IsPCFactionOrMinion && !EClass._zone.IsPCFactionOrTent && EClass._zone.HasLaw && pos.ListWitnesses(this).Count > 0 && !HasCondition<ConBurning>())
4031 {
4032 flag = false;
4033 }
4034 if (flag)
4035 {
4036 UseAbility("SpTransmuteBat", this);
4037 }
4038 }
4039 }
4040 if (HasElement(1423) && !HasCondition<ConPeaky>())
4041 {
4042 AddCondition<ConPeaky>();
4043 }
4044 break;
4045 }
4046 if (turn % 200 == 0)
4047 {
4048 DiminishTempElements();
4049 }
4050 if (IsPCParty)
4051 {
4052 if (dirtyWeight)
4053 {
4054 CalcBurden();
4055 }
4056 int phase2 = burden.GetPhase();
4057 int phase3 = hunger.GetPhase();
4058 if (phase3 >= 4)
4059 {
4060 preventRegen = true;
4061 }
4062 if (EClass.rnd(EClass._zone.IsRegion ? 100 : 30) == 0 && phase2 >= 3)
4063 {
4064 Say("dmgBurden", this);
4065 DamageHP(MaxHP * (base.ChildrenWeight * 100 / WeightLimit) / 1000 + 1, AttackSource.Burden);
4066 if (isDead)
4067 {
4068 return;
4069 }
4070 }
4071 if (EClass.rnd(12) == 0)
4072 {
4073 if (IsPC)
4074 {
4075 if (phase2 > 0)
4076 {
4077 ModExp(207, 1 + phase2 * phase2);
4078 }
4079 }
4080 else
4081 {
4082 ModExp(207, 4);
4083 }
4084 }
4085 if (IsPC)
4086 {
4087 if (phase3 >= 5)
4088 {
4089 if (!(ai is AI_Eat) && EClass.rnd(5) == 0)
4090 {
4091 DamageHP(1 + EClass.rnd(2) + MaxHP / 50, AttackSource.Hunger);
4092 }
4093 if (!isDead && EClass.rnd(3) == 0)
4094 {
4095 stamina.Mod(-1);
4096 }
4097 }
4098 if (isDead)
4099 {
4100 return;
4101 }
4102 phase3 = stamina.GetPhase();
4103 if (phase3 <= 0)
4104 {
4105 preventRegen = true;
4106 }
4107 if (currentZone.IsRegion && EClass.world.weather.CurrentCondition == Weather.Condition.RainHeavy && !EClass.pc.HasElement(408))
4108 {
4109 if (EClass.rnd(100) == 0 && !isConfused)
4110 {
4111 Msg.Say("rain_confuse");
4112 AddCondition<ConConfuse>(500);
4113 }
4114 if (EClass.rnd(300) == 0 && !isBlind)
4115 {
4116 Msg.Say("rain_confuse");
4117 AddCondition<ConBlind>(200);
4118 }
4119 }
4120 if (turn % (200000 / Mathf.Max(100 + Evalue(409) * 10, 50)) == 0)
4121 {
4122 ModCorruption(1);
4123 }
4124 }
4125 }
4126 if (!IsPC)
4127 {
4128 int num2 = Evalue(409);
4129 if (num2 > 0 && turn % (200000 / Mathf.Max(100 + num2 * 10, 50)) == 0)
4130 {
4131 ModCorruption(1);
4132 }
4133 }
4134 for (int num3 = conditions.Count - 1; num3 >= 0; num3--)
4135 {
4136 if (num3 < conditions.Count)
4137 {
4138 Condition condition = conditions[num3];
4139 if (!condition.TimeBased)
4140 {
4141 condition.Tick();
4142 }
4143 if (!condition.IsKilled)
4144 {
4145 if (condition.ConsumeTurn)
4146 {
4147 consumeTurn = true;
4148 }
4149 if (condition.PreventRegen)
4150 {
4151 preventRegen = true;
4152 }
4153 if (condition.EmoIcon != Emo2.none && condition.EmoIcon > emoIcon)
4154 {
4155 emoIcon = condition.EmoIcon;
4156 }
4157 }
4158 if (isDead)
4159 {
4160 return;
4161 }
4162 }
4163 }
4164 switch (id)
4165 {
4166 case "cocoon_alien":
4167 case "cocoon":
4168 if (!EClass._zone.IsRegion && !IsDisabled && 1.0005f - (float)base.hp / (float)MaxHP > EClass.rndf(1f) && !pos.IsSunLit)
4169 {
4170 HatchEgg();
4171 return;
4172 }
4173 consumeTurn = true;
4174 break;
4175 case "tsunami":
4176 if (elements.Base(79) >= 30)
4177 {
4178 if (IsInCombat)
4179 {
4180 elements.SetTo(79, elements.Base(79) * 3 / 4);
4181 }
4182 break;
4183 }
4184 Die();
4185 return;
4186 }
4187 if (pos.IsBlocked && pos.HasBlock)
4188 {
4189 preventRegen = true;
4190 }
4191 if (preventRegen)
4192 {
4193 return;
4194 }
4195 if (EClass.rnd(25) == 0 && base.hp < MaxHP)
4196 {
4197 HealHP(EClass.rnd(Evalue(300) / 3 + 1) + 1);
4198 elements.ModExp(300, 8f);
4199 }
4200 if (EClass.rnd(8) == 0 && mana.value < mana.max)
4201 {
4202 mana.Mod(EClass.rnd(Evalue(301) / 2 + 1) + 1);
4203 elements.ModExp(301, 8f);
4204 }
4205 if (EClass.rnd(20) != 0)
4206 {
4207 return;
4208 }
4209 if (IsPC)
4210 {
4212 {
4213 EClass.player.RecoverStamina(Evalue(62) / 100 + ((Evalue(62) % 100 > EClass.rnd(100)) ? 1 : 0));
4214 }
4215 }
4216 else if (stamina.value < stamina.max)
4217 {
4218 stamina.Mod(EClass.rnd(5) + 1);
4219 }
4220 }
4221
4222 public void SyncRide()
4223 {
4224 if (host != null)
4225 {
4226 host.SyncRide();
4227 }
4228 if (ride != null)
4229 {
4230 SyncRide(ride);
4231 }
4232 if (parasite != null)
4233 {
4234 SyncRide(parasite);
4235 }
4236 }
4237
4238 public void SyncRide(Chara c)
4239 {
4240 if (!c.pos.Equals(pos))
4241 {
4242 if (!pos.IsValid)
4243 {
4244 Debug.LogError("exception: pos is not valid:" + pos?.ToString() + "/" + this);
4245 pos = new Point();
4246 }
4247 EClass._map.MoveCard(pos, c);
4248 }
4249 }
4250
4251 public override void Tick()
4252 {
4253 SyncRide();
4254 combatCount--;
4255 ignoreSPAbsorb = false;
4256 if (IsPC)
4257 {
4258 if (hasMovedThisTurn)
4259 {
4260 pos.Things.ForeachReverse(delegate(Thing t)
4261 {
4263 {
4264 AI_Goto aI_Goto = ai.Current as AI_Goto;
4265 if ((aI_Goto == null && !(ai is GoalManualMove)) || (aI_Goto != null && !aI_Goto.dest.Equals(pos)))
4266 {
4267 return;
4268 }
4269 }
4270 t.trait.OnStepped(this);
4271 });
4272 if (isDead)
4273 {
4274 return;
4275 }
4276 hasMovedThisTurn = false;
4278 {
4279 EClass.player.haltMove = false;
4280 ActionMode.Adv.TryCancelInteraction(sound: false);
4281 EInput.Consume(1);
4282 return;
4283 }
4284 if (EClass._zone.IsRegion)
4285 {
4287 {
4288 foreach (Chara member in EClass.pc.party.members)
4289 {
4290 if (member.hunger.value > 65)
4291 {
4292 member.InstantEat(null, sound: false);
4293 }
4294 }
4295 }
4296 Chara chara = null;
4298 if (cell != null && (cell.zone == null || (cell.zone is Zone_Field && !cell.zone.IsPCFaction)))
4299 {
4300 foreach (Chara chara2 in EClass._map.charas)
4301 {
4302 if (!chara2.IsPCFactionOrMinion && !chara2.IsGlobal && chara2.pos.Equals(EClass.pc.pos))
4303 {
4304 chara = chara2;
4305 break;
4306 }
4307 }
4308 }
4309 if (chara != null)
4310 {
4312 {
4313 EClass.player.safeTravel = 5 + EClass.rnd(5);
4314 }
4315 EClass._zone.RemoveCard(chara);
4316 Msg.Say("encounter");
4317 EClass.player.EnterLocalZone(encounter: true, chara);
4318 }
4319 else if (EClass.player.safeTravel <= 0)
4320 {
4321 if (cell != null && cell.zone == null && !EClass.debug.ignoreEncounter)
4322 {
4324 if (!tileInfo.shore)
4325 {
4326 bool num = EClass.pc.HasCondition<ConWardMonster>();
4327 bool flag = EClass.pc.HasCondition<ConDrawMonster>();
4328 bool flag2 = EClass.game.quests.Get<QuestEscort>() != null;
4329 int num2 = (tileInfo.isRoad ? 22 : 12);
4330 if (flag2)
4331 {
4332 num2 = (tileInfo.isRoad ? 16 : 10);
4333 }
4334 if (num)
4335 {
4336 num2 *= (flag2 ? 2 : 20);
4337 }
4338 if (flag)
4339 {
4340 num2 /= 2;
4341 }
4342 if (EClass.rnd(num2) == 0)
4343 {
4344 Msg.Say("encounter");
4345 if (!flag)
4346 {
4347 EClass.player.safeTravel = 5 + EClass.rnd(5);
4348 }
4349 EClass.player.EnterLocalZone(encounter: true);
4350 }
4351 }
4352 }
4353 }
4354 else
4355 {
4357 }
4358 }
4359 }
4360 EClass.player.pickupDelay = 0f;
4361 if (EClass.player.returnInfo != null)
4362 {
4364 if (EClass.player.returnInfo.turns <= 0)
4365 {
4367 {
4368 EClass.player.returnInfo = null;
4370 }
4371 else
4372 {
4374 {
4375 int uidDest = EClass.player.returnInfo.uidDest;
4376 Zone zone = null;
4377 if (uidDest != 0)
4378 {
4379 zone = EClass.game.spatials.map.TryGetValue(uidDest) as Zone;
4380 }
4381 if (zone == null || zone.destryoed)
4382 {
4383 zone = EClass.world.region;
4384 }
4386 {
4387 Msg.Say("returnFail");
4388 }
4389 else
4390 {
4391 Msg.Say("returnComplete");
4392 EClass.player.uidLastTravelZone = 0;
4394 EClass.player.lastZonePos = null;
4395 }
4396 EClass.player.returnInfo = null;
4397 return;
4398 }
4399 EClass.player.returnInfo = null;
4400 Msg.Say("returnOverweight");
4401 }
4402 }
4403 }
4404 if ((HasNoGoal || !ai.IsRunning) && !WillConsumeTurn())
4405 {
4406 SetAI(_NoGoalPC);
4407 return;
4408 }
4411 {
4412 RecipeUpdater.dirty = true;
4413 }
4414 actTime = EClass.player.baseActTime;
4415 }
4416 else
4417 {
4418 actTime = EClass.player.baseActTime * Mathf.Max(0.1f, (float)EClass.pc.Speed / (float)Speed);
4419 hasMovedThisTurn = false;
4420 }
4421 TickConditions();
4422 if (!IsAliveInCurrentZone)
4423 {
4424 return;
4425 }
4426 renderer.RefreshStateIcon();
4427 if (host != null && !consumeTurn)
4428 {
4429 if (host.ride == this && ((host.hasMovedThisTurn && IsInCombat) || (enemy != null && turn % 3 != 0)))
4430 {
4431 consumeTurn = true;
4432 }
4433 if (host.parasite == this && enemy != null && EClass.rnd(10) > EClass.rnd(host.Evalue(227) + 10))
4434 {
4435 if (Dist(enemy) < 3 && EClass.rnd(2) == 0)
4436 {
4437 Say("parasite_fail", this, host);
4438 if (EClass.rnd(2) == 0 && GetInt(106) == 0)
4439 {
4440 Talk("parasite_fail");
4441 }
4442 }
4443 consumeTurn = true;
4444 }
4445 }
4446 if (consumeTurn)
4447 {
4448 if (IsPC)
4449 {
4451 }
4452 }
4453 else
4454 {
4455 if (base.isRestrained)
4456 {
4457 TryUnrestrain();
4458 }
4459 if (enemy != null)
4460 {
4462 {
4463 enemy = null;
4464 }
4465 else if (!IsPC && (ai.CancelOnAggro || !ai.IsRunning))
4466 {
4467 SetAIAggro();
4468 }
4469 }
4470 if (HasNoGoal || !ai.IsRunning)
4471 {
4472 ChooseNewGoal();
4473 }
4474 ai.Tick();
4475 }
4476 Cell cell2 = base.Cell;
4477 if (EClass._zone.IsUnderwater || (cell2.IsTopWaterAndNoSnow && !cell2.isFloating))
4478 {
4479 AddCondition<ConWet>(50);
4480 if (pos.IsHotSpring)
4481 {
4482 hygiene.Mod(2);
4483 }
4484 }
4485 if (cell2.sourceSurface.id == 20)
4486 {
4487 AddCondition<ConBurning>();
4488 }
4489 if (IsPC && !EClass._zone.IsRegion && cell2.CanSuffocate() && !EClass.debug.godMode && !HasElement(1252))
4490 {
4491 AddCondition<ConSuffocation>(800 / (100 + EvalueMax(200, -5) * 10), force: true);
4492 }
4493 CellEffect e;
4494 if (cell2.effect != null)
4495 {
4496 e = cell2.effect;
4497 switch (e.id)
4498 {
4499 case 1:
4500 case 2:
4501 case 4:
4502 if (IsLevitating)
4503 {
4504 Say("levitating");
4505 break;
4506 }
4507 AddCondition<ConWet>(50);
4508 ProcEffect();
4509 break;
4510 case 3:
4511 PlaySound("fire_step");
4512 AddCondition<ConBurning>(30);
4513 break;
4514 case 5:
4515 if (!isWet)
4516 {
4517 PlaySound("bubble");
4518 AddCondition<ConWet>(30);
4519 ProcEffect();
4520 }
4521 break;
4522 case 6:
4523 if (hasMovedThisTurn)
4524 {
4525 Say("abMistOfDarkness_step", this);
4526 }
4527 AddCondition<ConDark>(e.power);
4528 break;
4529 }
4530 }
4531 if (IsPC)
4532 {
4533 if (EClass.player.currentHotItem.Thing != null)
4534 {
4536 }
4538 }
4539 void ClearEffect()
4540 {
4541 EClass._map.SetLiquid(cell2.x, cell2.z, 0, 0);
4542 }
4543 void ProcEffect()
4544 {
4545 if (e.idEffect != EffectId.None)
4546 {
4547 ActEffect.ProcAt(e.idEffect, e.power, e.isBlessed ? BlessedState.Blessed : (e.isCursed ? BlessedState.Cursed : BlessedState.Normal), this, this, new Point(pos), e.isHostileAct, new ActRef
4548 {
4549 aliasEle = EClass.sources.elements.map[e.idEle].alias,
4550 n1 = e.n1,
4551 refVal = e.refVal
4552 });
4553 ClearEffect();
4554 }
4555 }
4556 }
4557
4558 public bool CanLift(Card c)
4559 {
4560 return true;
4561 }
4562
4563 public bool CanAutoPick(Card c)
4564 {
4565 return true;
4566 }
4567
4568 public bool CanPick(Card c)
4569 {
4570 if (c.isDestroyed)
4571 {
4572 return false;
4573 }
4574 Card rootCard = c.GetRootCard();
4575 if (rootCard.isDestroyed || (rootCard.ExistsOnMap && rootCard.pos.Distance(pos) > 1))
4576 {
4577 return false;
4578 }
4579 if (rootCard != this && things.IsFull(c.Thing))
4580 {
4581 return false;
4582 }
4583 return true;
4584 }
4585
4586 public void PickOrDrop(Point p, string idThing, int idMat = -1, int num = 1, bool msg = true)
4587 {
4588 if (num != 0)
4589 {
4590 PickOrDrop(p, ThingGen.Create(idThing, idMat).SetNum(num), msg);
4591 }
4592 }
4593
4594 public void PickOrDrop(Point p, Thing t, bool msg = true)
4595 {
4596 if (things.GetDest(t).IsValid)
4597 {
4598 Pick(t, msg);
4599 }
4600 else
4601 {
4602 EClass._zone.AddCard(t, p);
4603 }
4604 }
4605
4606 public Thing Pick(Thing t, bool msg = true, bool tryStack = true)
4607 {
4608 if (t.trait is TraitCard && t.isNew && EClass.game.config.autoCollectCard && !t.c_idRefCard.IsEmpty())
4609 {
4611 return t;
4612 }
4613 if (t.parent == this)
4614 {
4615 return t;
4616 }
4617 t = TryPoisonPotion(t);
4618 ThingContainer.DestData dest = things.GetDest(t, tryStack);
4619 if (!dest.IsValid)
4620 {
4621 if (t.parent != EClass._zone)
4622 {
4623 if (IsPC)
4624 {
4625 Say("backpack_full_drop", t);
4626 SE.Drop();
4627 }
4628 return EClass._zone.AddCard(t, pos).Thing;
4629 }
4630 if (IsPC)
4631 {
4632 Say("backpack_full", t);
4633 }
4634 return t;
4635 }
4636 if (dest.stack != null)
4637 {
4638 if (msg)
4639 {
4640 PlaySound("pick_thing");
4641 Say("pick_thing", this, t);
4642 }
4643 t.TryStackTo(dest.stack);
4644 return dest.stack;
4645 }
4646 TryAbsorbRod(t);
4647 if (msg)
4648 {
4649 PlaySound("pick_thing");
4650 Say("pick_thing", this, t);
4651 }
4652 TryReservePickupTutorial(t);
4653 return dest.container.AddThing(t, tryStack);
4654 }
4655
4657 {
4658 if (t.trait is TraitPotion && t.id != "1165" && !t.source.tag.Contains("neg") && EClass.rnd(2) == 0 && HasElement(1565))
4659 {
4660 string text = EClass.sources.things.rows.Where((SourceThing.Row a) => a._origin == "potion" && a.tag.Contains("neg") && a.chance > 100).ToList().RandomItemWeighted((SourceThing.Row a) => a.chance)
4661 .id;
4662 Say("poisonDrip", this);
4663 int num = t.Num;
4664 t.Destroy();
4665 t = ThingGen.Create(text).SetNum(num);
4666 }
4667 return t;
4668 }
4669
4670 public void TryAbsorbRod(Thing t)
4671 {
4672 if (!IsPC || !(t.trait is TraitRod) || t.c_charges <= 0 || !HasElement(1564))
4673 {
4674 return;
4675 }
4676 Say("absorbRod", this, t);
4677 TraitRod rod = t.trait as TraitRod;
4678 bool flag = false;
4679 if (rod.source != null)
4680 {
4681 using IEnumerator<SourceElement.Row> enumerator = EClass.sources.elements.rows.Where((SourceElement.Row a) => a.id == rod.source.id).GetEnumerator();
4682 if (enumerator.MoveNext())
4683 {
4684 SourceElement.Row current = enumerator.Current;
4685 if (IsPC)
4686 {
4687 GainAbility(current.id, t.c_charges * 100, t);
4688 flag = true;
4689 }
4690 }
4691 }
4692 if (!flag)
4693 {
4694 mana.Mod(-50 * t.c_charges);
4695 }
4696 t.c_charges = 0;
4698 }
4699
4701 {
4702 if (t.id == "axe")
4703 {
4704 Tutorial.Reserve("tool");
4705 }
4706 if (t.category.id == "mushroom")
4707 {
4708 Tutorial.Reserve("food");
4709 }
4710 if (t.category.id == "herb")
4711 {
4712 Tutorial.Reserve("herb");
4713 }
4714 if (t.id == "pasture")
4715 {
4716 Tutorial.Reserve("pasture");
4717 }
4718 if (t.id == "log")
4719 {
4720 Tutorial.Reserve("process");
4721 }
4722 }
4723
4724 public void TryPickGroundItem(Func<Card, bool> func = null)
4725 {
4726 foreach (Card item in pos.ListCards())
4727 {
4728 if ((IsPC || !(EClass.pc.ai is AI_UseCrafter aI_UseCrafter) || !aI_UseCrafter.ings.Contains(item)) && item.isThing && item.placeState == PlaceState.roaming && CanPick(item) && (func == null || func(item)))
4729 {
4730 Thing thing = Pick(item.Thing);
4731 if (thing != null && !IsPC)
4732 {
4733 thing.isNPCProperty = true;
4734 }
4735 break;
4736 }
4737 }
4738 }
4739
4740 public void TryPutShared(Thing t, List<Thing> containers = null, bool dropIfFail = true)
4741 {
4742 if (!EClass._zone.TryAddThingInSharedContainer(t, containers) && dropIfFail)
4743 {
4744 EClass._zone.AddCard(t, pos);
4745 }
4746 }
4747
4748 public bool TryHoldCard(Card t, int num = -1, bool pickHeld = false)
4749 {
4750 if (held == t)
4751 {
4752 return true;
4753 }
4754 if (t.isDestroyed || t.Num <= 0)
4755 {
4756 return false;
4757 }
4758 if (!CanPick(t))
4759 {
4760 if (t.parent == null)
4761 {
4762 EClass._zone.AddCard(t, pos);
4763 }
4764 return false;
4765 }
4766 HoldCard(t, num);
4767 return true;
4768 }
4769
4770 public void HoldCard(Card t, int num = -1)
4771 {
4772 if (held == t || t.isDestroyed || t.Num <= 0)
4773 {
4774 return;
4775 }
4776 if (IsPC && t.isNPCProperty)
4777 {
4778 t.isNPCProperty = false;
4779 if (!t.GetBool(128))
4780 {
4782 pos.TryWitnessCrime(this);
4783 }
4784 }
4785 PickHeld();
4786 if (t.isChara)
4787 {
4789 {
4790 t.ShowEmo(Emo.love);
4791 }
4792 EClass.player.altHeldPos = t.renderer.data.ForceAltHeldPosition || EClass.rnd(2) == 0;
4793 }
4794 else
4795 {
4796 if (num == -1 || num > t.Num)
4797 {
4798 num = t.Num;
4799 }
4800 if (num < t.Num)
4801 {
4802 t = t.Split(num);
4803 }
4804 }
4805 if (t.GetRootCard() != this)
4806 {
4807 t = Pick(t.Thing, msg: false, tryStack: false);
4808 if (t.GetRootCard() != this)
4809 {
4810 return;
4811 }
4812 }
4813 held = t;
4814 held._CreateRenderer();
4815 if (held.GetLightRadius() > 0)
4816 {
4817 RecalculateFOV();
4818 }
4819 if (IsPC)
4820 {
4822 WidgetHotbar.dirtyCurrentItem = true;
4823 }
4824 }
4825
4826 public void PickHeld(bool msg = false)
4827 {
4828 if (held == null)
4829 {
4830 return;
4831 }
4832 Card card = held;
4833 if (IsPC && held.invY == 1)
4834 {
4835 WidgetHotbar.dirtyCurrentItem = true;
4837 held = null;
4838 return;
4839 }
4840 if (held.isChara)
4841 {
4842 DropHeld();
4843 return;
4844 }
4845 if (IsPC && !held.IsHotItem && held.trait.CanOnlyCarry)
4846 {
4847 Say("canOnlyCarry", held);
4848 DropHeld();
4849 return;
4850 }
4851 bool flag = held != things.TryStack(held.Thing);
4852 if (!flag && things.IsOverflowing())
4853 {
4854 if (IsPC)
4855 {
4856 Say("backpack_full_drop", held);
4857 SE.Drop();
4858 }
4859 DropHeld();
4860 return;
4861 }
4862 if (msg)
4863 {
4864 PlaySound("pick_thing");
4865 Say("pick_held", this, card);
4866 if (IsPC && card.id == "statue_weird")
4867 {
4868 Say("statue_pick");
4869 }
4870 }
4871 if (IsPC)
4872 {
4873 WidgetHotbar.dirtyCurrentItem = true;
4874 if (!flag)
4875 {
4877 if (held.GetRootCard() != EClass.pc)
4878 {
4879 Pick(held.Thing, msg: false);
4880 }
4881 }
4882 }
4883 held = null;
4884 }
4885
4886 public Card SplitHeld(int a)
4887 {
4888 return held.Split(a);
4889 }
4890
4891 public void TryDropCarryOnly()
4892 {
4893 if (held != null && held.trait.CanOnlyCarry)
4894 {
4895 DropHeld();
4896 }
4897 foreach (Thing item in things.List((Thing t) => t.trait.CanOnlyCarry))
4898 {
4899 DropThing(item);
4900 }
4901 }
4902
4903 public Card DropHeld(Point dropPos = null)
4904 {
4905 if (held == null)
4906 {
4907 return null;
4908 }
4909 if (IsPC)
4910 {
4911 WidgetHotbar.dirtyCurrentItem = true;
4913 }
4914 Card card = EClass._zone.AddCard(held, dropPos ?? pos);
4915 card.OnLand();
4916 if (card.trait.CanOnlyCarry)
4917 {
4918 card.SetPlaceState(PlaceState.installed);
4919 }
4920 return card;
4921 }
4922
4923 public void DropThing(Thing t, int num = -1)
4924 {
4925 if (t.c_isImportant)
4926 {
4927 Msg.Say("markedImportant");
4928 return;
4929 }
4930 if (!t.trait.CanBeDropped)
4931 {
4932 Msg.Say("cantDrop", t);
4933 return;
4934 }
4935 if (t.trait is TraitAbility)
4936 {
4937 SE.Trash();
4938 t.Destroy();
4939 return;
4940 }
4941 Msg.Say("dropItem", t.Name);
4942 t.ignoreAutoPick = true;
4943 PlaySound("drop");
4944 EClass._zone.AddCard(t, pos);
4945 if (t.trait.CanOnlyCarry)
4946 {
4947 t.Install();
4948 }
4949 }
4950
4952 {
4953 int num = Evalue(131);
4954 int num2 = Evalue(130);
4955 int num3 = Evalue(123);
4956 if (num > num2 && num > num3)
4957 {
4958 return AttackStyle.TwoWield;
4959 }
4960 if (num2 > num && num2 > num3)
4961 {
4962 return AttackStyle.TwoHand;
4963 }
4964 if (num3 > num && num3 > num2)
4965 {
4966 return AttackStyle.Shield;
4967 }
4968 return AttackStyle.Default;
4969 }
4970
4972 {
4973 return elements.ListElements((Element e) => e.source.categorySub == "weapon" && !e.HasTag("ranged")).FindMax((Element a) => a.Value);
4974 }
4975
4977 {
4978 if (elements.Value(122) > elements.Value(120))
4979 {
4980 return elements.GetElement(122);
4981 }
4982 return elements.GetElement(120);
4983 }
4984
4985 public void TryRestock(bool onCreate)
4986 {
4987 isOnCreate = onCreate;
4988 if (onCreate || (!IsPCFaction && (base.IsUnique || trait is TraitAdventurer || trait is TraitGuard)))
4989 {
4990 RestockEquip((!EClass.core.IsGameStarted || !(EClass._zone is Zone_Music)) && onCreate);
4991 }
4992 RestockInventory(onCreate);
4993 }
4994
4995 public void RestockEquip(bool onCreate)
4996 {
4997 string equip = source.equip;
4998 if (equip.IsEmpty())
4999 {
5000 equip = job.equip;
5001 }
5002 if (equip == "none")
5003 {
5004 return;
5005 }
5006 bool flag = true;
5007 switch (id)
5008 {
5009 case "kettle":
5010 case "quru":
5011 case "loytel":
5012 case "shojo":
5013 EQ_ID("staff_long", 1);
5014 EQ_CAT("head");
5015 EQ_CAT("torso");
5016 EQ_CAT("arm");
5017 return;
5018 case "adv_yukiimo":
5019 if (onCreate)
5020 {
5021 EQ_ID("tail_snowleopard");
5022 }
5023 break;
5024 case "adv_kiria":
5025 if (onCreate)
5026 {
5027 EQ_ID("sword_zephir");
5028 }
5029 break;
5030 case "adv_schwert":
5031 if (onCreate)
5032 {
5033 EQ_ID("sword", -1, Rarity.Legendary);
5034 }
5035 if (onCreate)
5036 {
5037 EQ_ID("dagger", -1, Rarity.Legendary);
5038 }
5039 break;
5040 case "adv_mesherada":
5041 if (onCreate)
5042 {
5043 EQ_ID("dagger_hathaway");
5044 }
5045 break;
5046 case "adv_verna":
5047 if (onCreate)
5048 {
5049 EQ_ID("staff_long", -1, Rarity.Legendary);
5050 }
5051 if (onCreate)
5052 {
5053 EQ_ID("cloak_wing", -1, Rarity.Mythical);
5054 }
5055 break;
5056 case "big_sister":
5057 if (onCreate)
5058 {
5059 EQ_ID("sword_muramasa");
5060 }
5061 break;
5062 case "adv_gaki":
5063 if (onCreate)
5064 {
5065 EQ_ID("dagger_gaki");
5066 }
5067 if (onCreate)
5068 {
5069 EQ_ID("dagger_ninto");
5070 }
5071 break;
5072 case "adv_ivory":
5073 EQ_ID("dagger", -1, Rarity.Legendary);
5074 AddThing("60");
5075 break;
5076 case "adv_wini":
5077 if (onCreate)
5078 {
5079 EQ_ID("staff_Cat", -1, Rarity.Mythical);
5080 }
5081 AddCard(ThingGen.CreateSpellbook(9150));
5082 if (onCreate)
5083 {
5084 AddThing("1071");
5085 }
5086 break;
5087 case "mamani":
5088 EQ_ID("lightsaber_double", -1, Rarity.Mythical);
5089 if (onCreate)
5090 {
5091 EQ_ID("cloak_mani2");
5092 EQ_ID("boots_dal");
5093 AddThing("gun_gravity2");
5094 AddThing("gun_mani");
5095 }
5096 break;
5097 case "namamani":
5098 if (onCreate)
5099 {
5100 AddThing("gun_gravity2");
5101 }
5102 break;
5103 case "lomias":
5104 if (onCreate)
5105 {
5106 AddThing("bow_vindale");
5107 }
5108 break;
5109 case "unseenhand":
5110 if (onCreate)
5111 {
5112 EQ_ID("martial_ring");
5113 }
5114 break;
5115 case "larnneire":
5116 if (onCreate)
5117 {
5118 EQ_ID("EtherDagger2");
5119 }
5120 break;
5121 case "keeper_garden":
5122 if (!body.HasWeapon())
5123 {
5124 EQ_ID("sword_ragnarok");
5125 }
5126 break;
5127 case "ungaga_pap":
5128 if (onCreate)
5129 {
5130 EQ_ID("axe_destruction");
5131 }
5132 break;
5133 case "lurie_boss":
5134 if (onCreate)
5135 {
5136 EQ_ID("ribbon_duponne");
5137 }
5138 break;
5139 case "seeker":
5140 if (onCreate)
5141 {
5142 EQ_ID("helm_seeker");
5143 }
5144 EQ_ID("robe_pope");
5145 EQ_ID("sword_katana");
5146 EQ_ID("staff");
5147 EQ_ID("sword_katana");
5148 if (onCreate)
5149 {
5150 EQ_ID("boots_seven");
5151 }
5152 if (onCreate)
5153 {
5154 for (int i = 0; i < 20; i++)
5155 {
5156 AddThing(ThingGen.CreateFromCategory("book", 50));
5157 }
5158 EQ_Item("panty");
5159 AddThing("plat").SetNum(6);
5160 }
5161 break;
5162 case "ephrond":
5163 if (onCreate)
5164 {
5165 AddThing("guitar_efrond");
5166 }
5167 break;
5168 case "ashland":
5169 if (onCreate)
5170 {
5171 AddThing("guitar_ash");
5172 }
5173 break;
5174 case "swordkeeper":
5175 if (onCreate)
5176 {
5177 EQ_ID("EtherDagger");
5178 }
5179 break;
5180 case "mech_angel":
5181 if (onCreate)
5182 {
5183 Thing thing = ThingGen.Create("pole_holy");
5184 thing.SetReplica(on: true);
5185 thing.rarity = Rarity.Normal;
5186 thing.elements.SetTo(60, -15);
5187 thing.elements.SetTo(418, -100);
5188 thing.elements.SetTo(93, 50);
5189 AddThing(thing);
5190 body.Equip(thing);
5191 flag = false;
5192 }
5193 break;
5194 case "azzrasizzle":
5195 if (onCreate)
5196 {
5197 EQ_ID("staff_magius");
5198 }
5199 break;
5200 case "sorin":
5201 if (onCreate)
5202 {
5203 EQ_ID("staff_insanity");
5204 }
5205 break;
5206 case "robot":
5207 if (onCreate)
5208 {
5209 EQ_ID("sword_katana");
5210 }
5211 break;
5212 case "mimu":
5213 if (onCreate)
5214 {
5215 EQ_ID("staff_leek");
5216 }
5217 break;
5218 case "kumatan":
5219 if (onCreate)
5220 {
5221 EQ_ID("dagger_hocho");
5222 }
5223 break;
5224 case "mad_rich":
5225 if (onCreate)
5226 {
5227 int a = (EClass._zone.IsUserZone ? 200 : EClass.rndHalf(100 + (EClass.debug.enable ? 10 : EClass._zone.influence) * 50 + (int)Mathf.Sqrt(EClass._zone.DangerLv) * 100 + (int)Mathf.Sqrt(EClass.pc.FameLv) * 100 + EClass._zone.development * 10));
5228 ModCurrency(a);
5229 }
5230 break;
5231 }
5232 if (!TryEquipRanged())
5233 {
5234 switch (id)
5235 {
5236 case "tyche":
5237 case "trooper":
5238 case "mech_scarab":
5239 AddThing("gun_laser");
5240 break;
5241 case "youngladymaton":
5242 case "sister_catmaton":
5243 case "shojomaton":
5244 case "imotomaton":
5245 case "rocketman":
5246 {
5247 Thing thing2 = AddThing("panzerfaust");
5248 thing2.ChangeMaterial("iron");
5249 thing2.c_ammo = 0;
5250 break;
5251 }
5252 default:
5253 switch (equip)
5254 {
5255 case "archer":
5256 EQ_CAT((EClass.rnd(4) == 0) ? "crossbow" : "bow");
5257 break;
5258 case "inquisitor":
5259 case "gunner":
5260 EQ_CAT("gun");
5261 break;
5262 }
5263 break;
5264 }
5265 }
5266 int num = ((base.rarity >= Rarity.Mythical) ? (base.LV * 3) : ((base.rarity >= Rarity.Legendary) ? (base.LV * 2) : base.LV));
5267 if (trait is TraitAdventurer)
5268 {
5269 num *= 3;
5270 }
5271 if (race.id == "asura")
5272 {
5273 for (int j = 0; j < 4; j++)
5274 {
5275 EQ_CAT(job.weapon.RandomItem());
5276 }
5277 }
5278 for (int k = 0; k < ((!(race.id == "mutant")) ? 1 : Mathf.Min(2 + base.LV / 30, 20)); k++)
5279 {
5280 if (flag)
5281 {
5282 if (source.ContainsTag("boxer"))
5283 {
5284 EQ_CAT("martial");
5285 }
5286 else if (!job.weapon.IsEmpty())
5287 {
5288 if (race.id == "mutant" || (body.slotMainHand != null && body.slotMainHand.thing == null))
5289 {
5290 EQ_CAT(job.weapon.RandomItem());
5291 }
5292 if (race.id == "mutant" || (Evalue(131) > 0 && EClass.rnd(2) == 0))
5293 {
5294 EQ_CAT(job.weapon.RandomItem());
5295 }
5296 }
5297 }
5298 EQ_CAT("torso");
5299 if (EClass.rnd(num) > 5)
5300 {
5301 EQ_CAT("arm");
5302 }
5303 if (EClass.rnd(num) > 10)
5304 {
5305 EQ_CAT("head");
5306 }
5307 if (EClass.rnd(num) > 15)
5308 {
5309 EQ_CAT("back");
5310 }
5311 if (EClass.rnd(num) > 20)
5312 {
5313 EQ_CAT("ring");
5314 }
5315 if (EClass.rnd(num) > 25)
5316 {
5317 EQ_CAT("amulet");
5318 }
5319 if (EClass.rnd(num) > 30)
5320 {
5321 EQ_CAT("foot");
5322 }
5323 if (EClass.rnd(num) > 35)
5324 {
5325 EQ_CAT("waist");
5326 }
5327 if (EClass.rnd(num) > 40)
5328 {
5329 EQ_CAT("ring");
5330 }
5331 }
5332 if (trait is TraitBard)
5333 {
5334 AddThing(ThingGen.Create("lute"));
5335 if (EClass.debug.enable || EClass.rnd(100) == 0)
5336 {
5337 EQ_ID("shield_lute");
5338 }
5339 }
5340 if (HasTag(CTAG.shield))
5341 {
5342 EQ_CAT("shield");
5343 }
5344 }
5345
5346 public void RestockInventory(bool onCreate)
5347 {
5348 switch (id)
5349 {
5350 case "lomias":
5351 if (ShouldRestock("_meat"))
5352 {
5353 AddCard(ThingGen.Create("_meat").MakeRefFrom("begger"));
5354 }
5355 break;
5356 case "fiama":
5357 Restock("book_story", 1);
5358 break;
5359 case "rock_thrower":
5360 Restock("stone", 10 + EClass.rnd(10));
5361 break;
5362 case "giant":
5363 Restock("rock", 2 + EClass.rnd(10));
5364 break;
5365 case "farris":
5366 Restock("lute", 1);
5367 Restock("book_story_home", 1);
5368 break;
5369 case "begger":
5370 break;
5371 }
5372 void Restock(string id, int num)
5373 {
5374 if (ShouldRestock(id))
5375 {
5376 AddCard(ThingGen.Create(id).SetNum(num));
5377 }
5378 }
5379 bool ShouldRestock(string id)
5380 {
5381 return things.Find(id) == null;
5382 }
5383 }
5384
5385 private void SetEQQuality()
5386 {
5388 Rarity rarity = Rarity.Normal;
5389 int num = ((base.LV >= 1000) ? 7 : ((base.LV >= 500) ? 5 : ((base.LV >= 250) ? 3 : ((base.LV >= 100) ? 2 : ((base.LV >= 50) ? 1 : 0)))));
5390 Rarity rarity2 = base.rarity;
5391 if (id == "big_sister")
5392 {
5393 num = (isOnCreate ? 8 : 4);
5394 }
5395 if (!isOnCreate && EClass.rnd(10) != 0)
5396 {
5397 num /= 2;
5398 }
5399 if (rarity2 == Rarity.Superior && EClass.rnd(10) <= num)
5400 {
5401 rarity = Rarity.Superior;
5402 }
5403 else if (rarity2 == Rarity.Legendary)
5404 {
5405 rarity = ((EClass.rnd(10) <= num) ? Rarity.Legendary : ((EClass.rnd(5) <= num) ? Rarity.Superior : Rarity.Normal));
5406 }
5407 else if (rarity2 >= Rarity.Mythical)
5408 {
5409 rarity = ((EClass.rnd(30) <= num) ? Rarity.Mythical : ((EClass.rnd(10) > num) ? Rarity.Superior : Rarity.Legendary));
5410 }
5411 if (rarity == Rarity.Normal && EClass.rnd(1000) == 0)
5412 {
5413 rarity = Rarity.Legendary;
5414 }
5415 CardBlueprint.current.rarity = rarity;
5416 }
5417
5418 public Thing EQ_ID(string s, int mat = -1, Rarity r = Rarity.Random)
5419 {
5420 SetEQQuality();
5421 if (r != Rarity.Random)
5422 {
5423 CardBlueprint.current.rarity = r;
5424 }
5425 Thing thing = ThingGen.Create(s, mat, base.LV);
5426 if (body.GetSlot(thing, onlyEmpty: true) == null)
5427 {
5428 return thing;
5429 }
5430 AddThing(thing);
5431 if (!body.Equip(thing))
5432 {
5433 thing.Destroy();
5434 }
5435 return thing;
5436 }
5437
5438 public void EQ_CAT(string s)
5439 {
5440 int slot = EClass.sources.categories.map[s].slot;
5441 BodySlot bodySlot = ((slot == 0) ? null : body.GetSlot(slot));
5442 if ((slot == 0 || bodySlot != null) && (slot != 37 || !HasElement(1209)))
5443 {
5444 SetEQQuality();
5445 Thing thing = ThingGen.CreateFromCategory(s, base.LV);
5446 AddThing(thing);
5447 if (bodySlot != null && !body.Equip(thing, bodySlot))
5448 {
5449 thing.Destroy();
5450 }
5451 }
5452 }
5453
5454 public void EQ_Item(string s, int num = 1)
5455 {
5456 SetEQQuality();
5457 Thing t = ThingGen.Create(s, -1, base.LV).SetNum(num);
5458 AddThing(t);
5459 }
5460
5461 public void Drink(Card t)
5462 {
5463 Say("drink", this, t.Duplicate(1));
5464 Say("quaff");
5465 PlaySound("drink");
5466 t.ModNum(-1);
5467 FoodEffect.ProcDrink(this, t.Thing);
5468 _ = IsPC;
5469 }
5470
5471 public bool CanRevive()
5472 {
5473 return EClass.world.date.IsExpired(base.c_dateDeathLock);
5474 }
5475
5476 public void GetRevived()
5477 {
5478 Revive(EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false), msg: true);
5479 if (!IsPCFaction)
5480 {
5481 return;
5482 }
5483 if (!IsPC && (!trait.CanJoinPartyResident || !trait.CanJoinParty || memberType != FactionMemberType.Default))
5484 {
5485 if (homeZone != null && EClass._zone != homeZone)
5486 {
5487 Msg.Say("returnHome", this, homeZone.Name);
5488 MoveZone(homeZone);
5489 }
5490 }
5491 else if ((!EClass._zone.IsPCFaction || homeBranch != EClass.Branch || base.c_wasInPcParty) && EClass._zone.events.GetEvent<ZoneEventWedding>() == null)
5492 {
5493 EClass.pc.party.AddMemeber(this, showMsg: true);
5494 }
5495 }
5496
5497 public void Revive(Point p = null, bool msg = false)
5498 {
5499 if (!isDead)
5500 {
5501 return;
5502 }
5503 isDead = false;
5504 base.hp = MaxHP / 3;
5505 mana.value = 0;
5506 stamina.value = 0;
5507 if (hunger.value > 30)
5508 {
5509 hunger.value = 30;
5510 }
5511 sleepiness.value = 0;
5512 hostility = OriginalHostility;
5513 RemoveCondition<StanceTaunt>();
5514 if (id == "keeper_garden")
5515 {
5516 SaiyanRevive();
5517 }
5518 if (IsPC)
5519 {
5521 {
5522 Msg.Say("noDeathPenalty2", this);
5523 }
5525 {
5526 Msg.Say("noDeathPenalty", this);
5527 }
5528 else
5529 {
5531 }
5532 List<Thing> dropList = new List<Thing>();
5533 EClass.pc.things.Foreach(delegate(Thing t)
5534 {
5536 {
5537 t.ignoreAutoPick = true;
5538 dropList.Add(t);
5539 }
5540 }, onlyAccessible: false);
5541 foreach (Thing item in dropList)
5542 {
5544 Msg.Say("backpack_full_drop", item);
5545 }
5546 EClass.player.preventDeathPenalty = false;
5547 }
5548 if (IsPCFaction && homeBranch != null)
5549 {
5550 homeBranch.Log("bRevive", this);
5551 }
5552 if (p != null)
5553 {
5554 if (!p.IsInBounds)
5555 {
5557 }
5558 EClass._zone.AddCard(this, p);
5559 if (msg)
5560 {
5561 SE.Play("revive");
5562 Msg.Say("revive", this);
5563 PlayEffect("revive");
5564 }
5565 SetCensored(enable: false);
5566 }
5567 }
5568
5569 public void SaiyanRevive()
5570 {
5571 ModCorruption(-100000);
5572 if (base.LV < 10000000)
5573 {
5574 SetLv(base.LV * 10 + 9);
5575 }
5576 Refresh();
5577 base.hp = MaxHP;
5578 mana.value = mana.max;
5579 stamina.value = stamina.max;
5580 bossText = true;
5581 }
5582
5583 public void MakeGrave(string lastword)
5584 {
5585 if (!EClass._zone.IsRegion)
5586 {
5587 List<string> list = new List<string> { "930", "931", "947", "948", "949", "950", "951", "952" };
5588 if (IsPC && EClass.rnd(2) == 0 && EClass.pc.things.Find("letter_will") != null)
5589 {
5590 list = new List<string> { "944", "946", "backerGrave", "backerGrave2" };
5591 }
5592 Thing thing = ThingGen.Create(list.RandomItem());
5593 thing.MakeRefFrom(this);
5594 if (!lastword.IsEmpty())
5595 {
5596 thing.c_note = lastword;
5597 }
5598 thing.isModified = true;
5599 EClass._zone.AddCard(thing, pos).Install();
5600 }
5601 }
5602
5603 public void ApplyDeathPenalty()
5604 {
5605 if (!IsPC)
5606 {
5607 return;
5608 }
5609 int currency = GetCurrency();
5610 if (currency > 0)
5611 {
5612 int num = currency / 3 + EClass.rnd(currency / 3 + 1);
5613 if (num <= 0)
5614 {
5615 num = 1;
5616 }
5617 Msg.Say("panaltyMoney", this, Lang._currency(num));
5618 ModCurrency(-num);
5620 }
5621 foreach (Element value in EClass.pc.elements.dict.Values)
5622 {
5623 if (EClass.rnd(5) == 0 && value.IsMainAttribute)
5624 {
5625 EClass.pc.elements.ModExp(value.id, -500f);
5626 }
5627 }
5628 }
5629
5630 public void Vomit()
5631 {
5632 base.c_vomit++;
5633 Say("vomit", this);
5634 PlaySound("vomit");
5635 if (!EClass._zone.IsRegion)
5636 {
5637 Thing thing = ThingGen.Create("731");
5639 {
5640 thing.MakeRefFrom(this);
5641 }
5642 EClass._zone.AddCard(thing, pos);
5643 }
5644 if (HasCondition<ConAnorexia>())
5645 {
5646 ModExp(70, -50);
5647 ModExp(71, -75);
5648 ModExp(77, -100);
5649 }
5650 else if (base.c_vomit > 10)
5651 {
5652 AddCondition<ConAnorexia>();
5653 }
5654 AddCondition<ConDim>();
5655 if (HasCondition<ConAnorexia>())
5656 {
5657 ModWeight(-1 * (1 + EClass.rnd(5)));
5658 }
5659 if (hunger.GetPhase() >= 4)
5660 {
5661 DamageHP(9999L, AttackSource.Hunger);
5662 }
5663 hunger.Mod(30);
5664 }
5665
5666 public override void Die(Element e = null, Card origin = null, AttackSource attackSource = AttackSource.None, Chara originalTarget = null)
5667 {
5668 combatCount = 0;
5669 if (isDead)
5670 {
5671 return;
5672 }
5673 if (host != null)
5674 {
5675 base.hp = -1;
5676 if ((uint)(attackSource - 17) > 1u)
5677 {
5678 AddCondition<ConFaint>(200, force: true);
5679 return;
5680 }
5681 ActRide.Unride(host, this);
5682 }
5683 bool isInActiveZone = IsInActiveZone;
5684 if (isInActiveZone)
5685 {
5686 if (id == "putty" && origin != null && origin.IsPCParty)
5687 {
5689 }
5690 if (IsPC)
5691 {
5693 }
5694 if (base.isSummon)
5695 {
5696 if (id == "tsunami")
5697 {
5698 pos.PlaySound("water");
5699 }
5700 else
5701 {
5702 Say("summon_vanish", this);
5703 pos.PlayEffect("vanish");
5704 pos.PlaySound("vanish");
5705 }
5706 Destroy();
5707 return;
5708 }
5709 if ((uint)(attackSource - 17) <= 1u)
5710 {
5711 if (attackSource == AttackSource.Euthanasia && trait is TraitLittleOne)
5712 {
5713 MakeEgg();
5714 if (IsPCFaction)
5715 {
5716 homeBranch.RemoveMemeber(this);
5717 }
5718 }
5719 PlayEffect("revive");
5720 PlaySound("chime_angel");
5721 }
5722 else
5723 {
5724 Effect.Get("blood").Play((parent is Chara) ? (parent as Chara).pos : pos).SetParticleColor(EClass.Colors.matColors[base.material.alias].main)
5725 .Emit(50);
5726 AddBlood(AI_Slaughter.slaughtering ? 12 : (2 + EClass.rnd(2)));
5727 PlaySound(base.material.GetSoundDead(source));
5728 }
5729 renderer.RefreshSprite();
5730 renderer.RefreshStateIcon();
5731 ClearFOV();
5732 }
5733 if (base.hp >= 0)
5734 {
5735 base.hp = -1;
5736 }
5737 string text = "";
5738 "dead_in".langGame(EClass._zone.Name);
5739 string text2 = ((origin == null) ? "" : origin.GetName(NameStyle.Full));
5740 if (LangGame.Has("dead_" + attackSource))
5741 {
5742 text = "dead_" + attackSource;
5743 }
5744 else
5745 {
5746 if (e != Element.Void && e != null)
5747 {
5748 text = "dead_" + e.source.alias;
5749 }
5750 if (text == "" || !LangGame.Has(text))
5751 {
5752 text = "dead";
5753 }
5754 }
5755 if (IsPC)
5756 {
5757 EClass.player.staminaRecovery = 0;
5758 EClass._zone.isDeathLocation = true;
5759 string s = ((origin == null) ? text : "dead_by");
5761 if (attackSource == AttackSource.Wrath)
5762 {
5764 }
5765 EClass.player.deathMsg = GameLang.Parse(s.langGame(), thirdPerson: true, EClass.pc.NameBraced, "dead_in".langGame(EClass._zone.Name), text2);
5767 if (EClass._zone.instance is ZoneInstanceRandomQuest zoneInstanceRandomQuest)
5768 {
5769 zoneInstanceRandomQuest.status = ZoneInstance.Status.Fail;
5770 }
5771 AI_PlayMusic.keepPlaying = false;
5772 }
5773 if (isInActiveZone)
5774 {
5775 if (attackSource == AttackSource.DeathSentence || attackSource == AttackSource.Euthanasia)
5776 {
5777 Msg.Say("goto_heaven", this);
5778 }
5779 else
5780 {
5781 if (originalTarget != null || origin == null || !origin.isSynced || (attackSource != AttackSource.Melee && attackSource != AttackSource.Range))
5782 {
5783 Msg.Say(text, this, "", text2);
5784 }
5785 string text3 = TalkTopic("dead");
5786 if (!text3.IsEmpty())
5787 {
5788 text3 = text3.StripBrackets();
5789 }
5790 bool flag = base.rarity >= Rarity.Legendary && !IsPCFaction;
5791 if (!IsPC && flag)
5792 {
5793 MakeGrave(text3);
5794 }
5795 Msg.SetColor();
5796 SpawnLoot(origin);
5797 }
5798 if (IsPC)
5799 {
5800 TryDropCarryOnly();
5801 }
5802 }
5803 if (IsPCFaction)
5804 {
5805 if (homeBranch != null)
5806 {
5807 homeBranch.Log(text, this, "");
5808 }
5809 WidgetPopText.Say("popDead".lang(base.Name), FontColor.Bad);
5810 if (!IsPC)
5811 {
5812 if (EClass.player.stats.allyDeath == 0)
5813 {
5814 Tutorial.Reserve("death_pet");
5815 }
5817 }
5818 }
5819 if (id == "mandrake" || HasElement(488))
5820 {
5821 Say("a_scream", this);
5822 ActEffect.ProcAt(EffectId.Scream, base.LV * 3 + 200, BlessedState.Normal, this, this, pos, isNeg: true);
5823 }
5824 daysStarved = 0;
5825 isDead = true;
5826 ClearTempElements();
5827 enemy = null;
5828 _cooldowns = null;
5829 base.isSale = false;
5830 SetInt(70);
5831 EClass._map.props.sales.Remove(this);
5832 Cure(CureType.Death);
5833 SetAI(new NoGoal());
5834 TryDropBossLoot();
5835 if (isInActiveZone && EClass._zone.HasLaw && IsHuman && OriginalHostility >= Hostility.Neutral)
5836 {
5837 pos.TalkWitnesses(origin?.Chara, "witness", 3, WitnessType.crime, (Chara c) => !c.IsPCParty && !c.IsUnique);
5838 }
5839 if (IsPC)
5840 {
5841 EClass.player.returnInfo = null;
5842 EClass.player.uidLastTravelZone = 0;
5843 foreach (Chara chara3 in EClass._map.charas)
5844 {
5845 if (chara3.IsHostile())
5846 {
5847 chara3.hostility = chara3.OriginalHostility;
5848 }
5849 if (chara3.enemy == EClass.pc)
5850 {
5851 chara3.enemy = null;
5852 }
5853 }
5854 if (EClass.pc.things.Find("letter_will") != null && EClass.rnd(10) == 0)
5855 {
5856 EClass.player.preventDeathPenalty = true;
5857 }
5858 }
5859 else
5860 {
5861 bool flag2 = currentZone.IsActiveZone && IsLocalChara && !currentZone.IsPCFaction;
5862 if (currentZone is Zone_LittleGarden && id == "littleOne")
5863 {
5864 flag2 = false;
5865 }
5866 if (flag2)
5867 {
5868 EClass._map.deadCharas.Add(this);
5869 }
5870 currentZone.RemoveCard(this);
5871 }
5872 if ((origin != null && origin.IsPCParty) || IsPCFaction)
5873 {
5874 int a = -10;
5875 if (IsPCFaction && !IsPCParty && (origin == null || !origin.IsPCParty))
5876 {
5877 a = -5;
5878 }
5879 ModAffinity(EClass.pc, a, show: false);
5880 string text4 = id;
5881 if (!(text4 == "quru"))
5882 {
5883 if (text4 == "corgon")
5884 {
5885 EClass.game.cards.globalCharas.Find("quru")?.ModAffinity(EClass.pc, -20, show: false);
5886 }
5887 }
5888 else
5889 {
5890 EClass.game.cards.globalCharas.Find("corgon")?.ModAffinity(EClass.pc, -20, show: false);
5891 }
5892 }
5893 if (origin != null)
5894 {
5895 if (origin.IsPCParty || origin.IsPCPartyMinion)
5896 {
5897 int num = 0;
5898 if (trait is TraitMerchantTravel && !base.isSummon)
5899 {
5900 num = -20;
5901 }
5902 else if (OriginalHostility >= Hostility.Friend && IsHuman && !base.IsPCFactionOrMinion)
5903 {
5904 num = -5;
5905 }
5906 else if (race.id == "cat" && OriginalHostility >= Hostility.Neutral)
5907 {
5908 EClass.pc.Say("killcat");
5909 num = -1;
5910 }
5911 if (EClass.pc.party.HasElement(1563) && num < 0)
5912 {
5913 num = num * 30 / 100;
5914 }
5915 if (num != 0)
5916 {
5917 EClass.player.ModKarma(num);
5918 }
5919 }
5920 if (origin == EClass.pc)
5921 {
5922 EClass.pc.faith.Revelation("kill", EClass.pc, 10);
5923 }
5924 else if (origin.IsPCFaction)
5925 {
5926 origin.Chara.ModAffinity(EClass.pc, 1, show: false);
5927 origin.Chara.ShowEmo(Emo.love);
5928 }
5929 }
5930 if (base.sourceBacker != null && origin != null && origin.IsPCParty)
5931 {
5932 EClass.player.doneBackers.Add(base.sourceBacker.id);
5933 }
5934 if (base.IsPCFactionOrMinion)
5935 {
5937 {
5938 Msg.Say("abort_allyDead");
5939 }
5940 }
5942 {
5943 Msg.Say("abort_enemyDead");
5944 }
5945 if (IsPCParty && !IsPC)
5946 {
5948 base.c_wasInPcParty = true;
5949 EClass.pc.Say("allyDead");
5950 }
5951 switch (id)
5952 {
5953 case "littleOne":
5954 if (attackSource != AttackSource.Euthanasia && !IsPCFaction)
5955 {
5956 EClass.player.flags.little_killed = true;
5958 }
5959 break;
5960 case "big_daddy":
5961 case "big_daddy2":
5962 if (!IsPCFaction)
5963 {
5964 Chara chara = CharaGen.Create("littleOne");
5965 EClass._zone.AddCard(chara, pos.Copy());
5966 Msg.Say("little_pop");
5968 }
5969 break;
5970 case "shark_sister":
5971 if (!IsPCFaction)
5972 {
5973 Chara t = CharaGen.Create("sister_shark");
5974 EClass._zone.AddCard(t, pos.Copy());
5975 Msg.Say("shark_pop");
5976 }
5977 break;
5978 }
5979 if (attackSource == AttackSource.Finish && origin != null && origin.Evalue(665) > 0)
5980 {
5981 Chara chara2 = CharaGen.CreateFromFilter("c_plant", base.LV);
5982 EClass._zone.AddCard(chara2, pos.Copy());
5983 if (chara2.LV < base.LV)
5984 {
5985 chara2.SetLv(base.LV);
5986 }
5987 chara2.MakeMinion((origin.IsPCParty || origin.IsPCPartyMinion) ? EClass.pc : origin.Chara, MinionType.Friend);
5988 Msg.Say("plant_pop", this, chara2);
5989 }
5992 trait.OnDie();
5993 }
5994
5995 public void TryDropBossLoot()
5996 {
5997 if (IsPCFaction || IsPCFactionMinion)
5998 {
5999 return;
6000 }
6001 int num = 0;
6002 bool flag = false;
6003 bool flag2 = false;
6004 Point point = pos.GetNearestPoint(allowBlock: true, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? pos;
6005 TreasureType type = TreasureType.BossQuest;
6006 if (EClass._zone.Boss == this)
6007 {
6008 type = TreasureType.BossNefia;
6009 num = 2 + EClass.rnd(2);
6010 flag = (flag2 = true);
6011 EClass._zone.Boss = null;
6012 Msg.Say("boss_win", EClass._zone.Name);
6014 {
6015 Msg.Say("boss_win_void", EClass._zone.Name);
6016 EClass.player.flags.KilledBossInVoid = true;
6017 }
6018 if (EClass._zone.IsNefia)
6019 {
6022 SE.Play("Jingle/fanfare2");
6023 EClass._zone.SetBGM(114, refresh: true, 3f);
6024 }
6027 }
6028 switch (id)
6029 {
6030 case "azzrasizzle":
6031 num = 5;
6032 flag = (flag2 = true);
6033 EClass.Sound.StopBGM(3f);
6034 EClass._zone.SetBGM(1, refresh: false);
6036 {
6037 EClass.game.quests.Get<QuestIntoDarkness>().UpdateOnTalk();
6038 }
6039 break;
6040 case "vernis_boss":
6041 num = 5;
6042 flag = (flag2 = true);
6043 EClass.Sound.StopBGM(3f);
6044 EClass._zone.SetBGM(1, refresh: false);
6046 {
6047 EClass.game.quests.Get<QuestVernis>().UpdateOnTalk();
6048 }
6049 break;
6050 case "lurie_boss":
6051 if (!(EClass._zone is Zone_Exile))
6052 {
6053 num = 5;
6054 flag = (flag2 = true);
6055 EClass._zone.SetBGM(120, refresh: true, 3f);
6057 {
6058 EClass.game.quests.Get<QuestNegotiationDarkness>().ChangePhase(4);
6059 EClass.player.flags.killedDuponne = true;
6060 }
6061 }
6062 break;
6063 case "ungaga_pap":
6064 num = 5;
6065 flag = (flag2 = true);
6067 {
6068 EClass._zone.SetBGM(46, refresh: true, 3f);
6069 }
6070 break;
6071 case "melilith_boss":
6072 num = 5;
6073 flag = (flag2 = true);
6074 EClass.Sound.StopBGM(3f);
6075 EClass._zone.SetBGM(1, refresh: false);
6076 break;
6077 case "doga":
6078 {
6079 QuestCurry questCurry = EClass.game.quests.Get<QuestCurry>();
6080 if (questCurry != null)
6081 {
6082 num = 5;
6083 flag = (flag2 = true);
6084 EClass.Sound.StopBGM(3f);
6085 EClass._zone.SetBGM(1, refresh: false);
6086 questCurry.NextPhase();
6087 }
6088 break;
6089 }
6090 case "fairy_raina":
6091 case "fairy_poina":
6092 {
6093 bool num2 = EClass._map.FindChara((id == "fairy_raina") ? "fairy_poina" : "fairy_raina") == null;
6094 QuestNasu questNasu = EClass.game.quests.Get<QuestNasu>();
6095 if (num2 && questNasu != null && questNasu.phase <= 1)
6096 {
6097 if (questNasu.phase == 0)
6098 {
6099 questNasu.NextPhase();
6100 }
6101 num = 5;
6102 flag = (flag2 = true);
6103 EClass.Sound.StopBGM(3f);
6104 EClass._zone.SetBGM(1, refresh: false);
6105 EClass.player.DropReward(ThingGen.Create("backpack_holding"));
6106 questNasu.NextPhase();
6107 }
6108 break;
6109 }
6110 case "isygarad":
6111 {
6112 num = 5;
6113 flag = (flag2 = true);
6114 QuestExploration questExploration = EClass.game.quests.Get<QuestExploration>();
6115 if (questExploration != null)
6116 {
6117 SE.Play("kill_boss");
6118 questExploration.ChangePhase(3);
6119 EClass.Sound.StopBGM(3f);
6120 EClass._zone.SetBGM(1, refresh: false);
6121 }
6122 break;
6123 }
6124 case "swordkeeper":
6125 num = 10;
6126 flag = true;
6127 SE.Play("kill_boss");
6128 SoundManager.ForceBGM();
6129 LayerDrama.Activate("_event", "event", "swordkeeper_defeat");
6130 break;
6131 }
6132 if (flag)
6133 {
6134 SE.Play("kill_boss");
6135 }
6136 if (num != 0)
6137 {
6139 {
6140 EClass.player.stats.deepest = EClass._zone.DangerLv;
6141 Msg.Say("update_deepest", EClass.player.stats.deepest.ToString() ?? "");
6142 }
6144 {
6145 EClass.player.stats.deepestVoid = -EClass._zone.lv;
6146 Msg.Say("update_deepest_void", EClass.player.stats.deepestVoid.ToString() ?? "");
6147 }
6148 EClass.player.willAutoSave = true;
6149 Thing thing = ThingGen.CreateTreasure("chest_boss", base.LV, type);
6150 point.SetBlock();
6151 point.SetObj();
6152 EClass._zone.AddCard(thing, point).Install();
6153 ThingGen.TryLickChest(thing);
6154 }
6155 if (flag2)
6156 {
6158 }
6159 }
6160
6161 public bool UseAbility(int idAct, Card tc = null, Point pos = null, bool pt = false)
6162 {
6163 return UseAbility(elements.GetElement(idAct)?.act ?? ACT.Create(idAct), tc, pos, pt);
6164 }
6165
6166 public bool UseAbility(string idAct, Card tc = null, Point pos = null, bool pt = false)
6167 {
6168 return UseAbility(elements.GetElement(idAct)?.act ?? ACT.Create(idAct), tc, pos, pt);
6169 }
6170
6171 public bool UseAbility(Act a, Card tc = null, Point pos = null, bool pt = false)
6172 {
6173 if (HasCooldown(a.id))
6174 {
6175 return false;
6176 }
6177 if (!a.ValidatePerform(this, tc, pos))
6178 {
6179 return false;
6180 }
6181 if (a.source.proc.TryGet(0) == "Heal" && HasElement(1422) && !IsPC)
6182 {
6183 List<int> list = new List<int> { 8400, 8401, 8402, 8403, 8404, 8405 };
6184 int num = list.IndexOf(a.id);
6185 if (num != -1)
6186 {
6187 int num2 = list.TryGet(num + Evalue(1422));
6188 a = elements.GetElement(num2)?.act ?? ACT.Create(num2);
6189 }
6190 }
6191 int num3 = 1;
6192 Act.Cost cost = a.GetCost(this);
6193 a.GetPower(this);
6194 int n = 1;
6195 int num4 = 0;
6196 bool flag = a.IsTargetHostileParty();
6197 bool flag2 = ability.Has(a.id);
6198 if (IsPC && HasCondition<StanceManaCost>())
6199 {
6200 num4 = Evalue(1657);
6201 }
6202 _pts.Clear();
6203 if (a.TargetType.ForceParty)
6204 {
6205 pt = true;
6206 }
6207 if (pt)
6208 {
6209 n = 0;
6210 if (flag)
6211 {
6212 ForeachEnemy(delegate
6213 {
6214 n++;
6215 });
6216 }
6217 else
6218 {
6219 ForeachParty(delegate
6220 {
6221 n++;
6222 });
6223 }
6224 }
6225 if (a is Spell && IsPC && a.vPotential < n && !flag2)
6226 {
6227 n = 1;
6228 _pts.Clear();
6229 _pts.Add(this);
6230 pt = false;
6231 }
6232 int num5 = 100;
6233 if (!a.TargetType.ForceParty && n > 1)
6234 {
6235 num5 = (IsPC ? (n * 100) : (50 + n * 50));
6236 }
6237 int num6 = cost.cost * num5 / 100;
6238 if (cost.type == Act.CostType.MP && Evalue(483) > 0)
6239 {
6240 num6 = num6 * 100 / (100 + (int)Mathf.Sqrt(Evalue(483) * 10) * 3);
6241 }
6242 if (n == 0)
6243 {
6244 if (IsPC)
6245 {
6247 }
6248 return false;
6249 }
6250 if (!IsPC && cost.type == Act.CostType.MP && mana.value < 0 && (EClass.rnd(4) != 0 || IsPCFaction || (base.IsPowerful && mana.value < -20)))
6251 {
6252 return false;
6253 }
6254 if (IsPC)
6255 {
6256 if (!Dialog.warned && cost.type == Act.CostType.MP && cost.cost > 0 && mana.value < num6 && !EClass.debug.godMode)
6257 {
6258 Card cardBk = EClass.scene.mouseTarget.card;
6259 ActPlan.warning = true;
6260 Dialog.TryWarnMana(delegate
6261 {
6262 EClass.scene.mouseTarget.card = cardBk;
6263 if (UseAbility(a, tc, pos, pt))
6264 {
6266 }
6267 });
6268 return false;
6269 }
6270 EClass.ui.CloseLayers();
6271 }
6272 if ((isConfused && EClass.rnd(4) == 0) || (isBlind && (pt || (pos != null && !pos.Equals(base.pos)) || (tc != null && tc.pos != null && !tc.pos.Equals(base.pos))) && EClass.rnd(2) == 0))
6273 {
6274 Say("shakeHead", this);
6275 return true;
6276 }
6277 if (tc != null && tc != this)
6278 {
6279 LookAt(tc.pos);
6280 }
6281 if (pos != null && !base.pos.Equals(pos))
6282 {
6283 LookAt(pos);
6284 }
6285 if (a.CanRapidFire && HasElement(1648))
6286 {
6287 num3 = 1 + Evalue(1648);
6288 }
6289 if (IsPC && cost.cost > 0 && a.Value == 0 && !flag2)
6290 {
6292 return false;
6293 }
6294 if (a is Spell)
6295 {
6296 string s = (isConfused ? "_cast_confuse" : (HasCondition<ConDim>() ? "_cast_dim" : ""));
6297 if (!a.source.tag.Contains("useHand"))
6298 {
6299 Say(race.castStyle.IsEmpty("cast"), this, a.source.GetName().ToLower(), s.lang());
6300 }
6301 if (IsPC)
6302 {
6303 _ = (n + 1) / 2;
6304 if (a.vPotential < n && !flag2)
6305 {
6306 Msg.Say("noSpellStock");
6307 EInput.Consume();
6308 return false;
6309 }
6310 if (num4 > 0 && (a.vPotential >= n * 2 || flag2))
6311 {
6312 if (!flag2)
6313 {
6314 a.vPotential -= n * 2;
6315 }
6316 num6 = num6 * (100 - num4 * 20) / 100;
6317 }
6318 else if (!flag2)
6319 {
6320 a.vPotential -= n;
6321 }
6323 }
6324 }
6325 else
6326 {
6327 if (IsPC && a.vPotential < 0 && !flag2 && !a.HasTag("dontForget"))
6328 {
6329 Msg.Say("noSpellStock");
6330 EInput.Consume();
6331 return false;
6332 }
6333 if (a.source.langAct.Length != 0 && tc != null)
6334 {
6335 string text = a.source.langAct[0];
6336 string text2 = ((a.source.langAct.Length >= 2) ? a.source.langAct[1] : "");
6337 if (text == "spell_hand")
6338 {
6339 string[] list2 = Lang.GetList("attack" + race.meleeStyle.IsEmpty("Touch"));
6340 string @ref = text2.lang(list2[4]);
6341 Say(tc.IsPCParty ? "cast_hand_ally" : "cast_hand", this, tc, @ref, tc.IsPCParty ? list2[1] : list2[2]);
6342 }
6343 else
6344 {
6345 Say(text, this, tc, text2.IsEmpty() ? "" : text2.lang());
6346 }
6347 if (a.source.id == 6630)
6348 {
6349 Talk("insult_" + (base.IsMale ? "m" : "f"));
6350 }
6351 }
6352 }
6353 switch (cost.type)
6354 {
6355 case Act.CostType.MP:
6356 if (Evalue(1421) >= 2 && base.hp <= MaxHP / Mathf.Max(1, 9 - Evalue(1421) * 2))
6357 {
6358 num6 /= 2;
6359 }
6360 if (isSynced)
6361 {
6362 PlayEffect("cast");
6363 }
6364 mana.Mod(-num6);
6365 if (isDead)
6366 {
6367 return true;
6368 }
6369 elements.ModExp(304, Mathf.Clamp(num6 * 2, 1, 200));
6370 break;
6371 case Act.CostType.SP:
6372 {
6373 int value = stamina.value;
6374 stamina.Mod(-num6);
6375 if (IsPC && a.HasTag("recovery"))
6376 {
6377 EClass.player.staminaRecovery += value - stamina.value;
6378 }
6379 ignoreSPAbsorb = true;
6380 break;
6381 }
6382 }
6383 if (a is Spell && GetCondition<ConSilence>() != null)
6384 {
6385 Say("cast_silence", this);
6386 return true;
6387 }
6388 if (isDead)
6389 {
6390 return true;
6391 }
6392 int spellExp = elements.GetSpellExp(this, a, num5);
6393 if (EClass.rnd(100) >= CalcCastingChance(a, n) && !EClass.debug.godMode)
6394 {
6395 Say("fizzle", this);
6396 PlayEffect("fizzle");
6397 PlaySound("fizzle");
6398 if (cost.cost > 0 && a.source.lvFactor > 0)
6399 {
6400 ModExp(a.id, spellExp / 5);
6401 }
6402 RemoveCondition<ConInvisibility>();
6403 return true;
6404 }
6405 bool flag3 = true;
6406 if (a.source.cooldown > 0 && (!IsPC || !a.source.tag.Contains("CD_npc")))
6407 {
6408 AddCooldown(a.id, a.source.cooldown);
6409 }
6410 if (HasTalk("phrase_" + a.source.alias))
6411 {
6412 EClass.player.forceTalk = true;
6413 Talk("phrase_" + a.source.alias);
6414 }
6415 if (pt)
6416 {
6417 Act.forcePt = true;
6418 if (flag)
6419 {
6420 ForeachEnemy(delegate(Chara c)
6421 {
6422 a.Perform(this, c, c.pos);
6423 });
6424 }
6425 else
6426 {
6427 ForeachParty(delegate(Chara c)
6428 {
6429 a.Perform(this, c, c.pos);
6430 });
6431 }
6432 Act.forcePt = false;
6433 }
6434 else
6435 {
6436 for (int num7 = 0; num7 < num3; num7++)
6437 {
6438 if (a.TargetType != TargetType.SelfParty && tc != null && !tc.IsAliveInCurrentZone)
6439 {
6440 break;
6441 }
6442 ActEffect.RapidCount = num7;
6443 ActEffect.RapidDelay = a.RapidDelay;
6444 flag3 = a.Perform(this, tc, pos);
6445 }
6446 }
6447 if (flag3 && !isDead)
6448 {
6449 if (IsPC && flag2 && elements.Base(a.id) == 0 && a.PotentialAsStock)
6450 {
6451 elements.ModBase(a.id, 1);
6452 }
6453 if (cost.cost > 0 && a.source.lvFactor > 0)
6454 {
6455 ModExp(a.id, spellExp);
6456 }
6457 }
6458 ActEffect.RapidCount = 0;
6459 if (flag3 && !a.source.tag.Contains("keepInvisi") && EClass.rnd(2) == 0)
6460 {
6461 RemoveCondition<ConInvisibility>();
6462 RemoveCondition<ConDark>();
6463 }
6464 if (!base.IsPCFactionOrMinion && a.HasTag("specialAbility") && renderer.isSynced)
6465 {
6466 string name = a.Name;
6467 renderer.Say("| " + name + " ");
6468 }
6469 return flag3;
6470 void ForeachEnemy(Action<Chara> action)
6471 {
6472 if (_pts.Count == 0)
6473 {
6474 for (int num8 = EClass._map.charas.Count - 1; num8 >= 0; num8--)
6475 {
6476 Chara chara = EClass._map.charas[num8];
6477 if (chara != this && CanSeeLos(chara) && chara.IsHostile(this))
6478 {
6479 _pts.Add(chara);
6480 }
6481 }
6482 }
6483 for (int num9 = _pts.Count - 1; num9 >= 0; num9--)
6484 {
6485 action(_pts[num9]);
6486 }
6487 }
6488 void ForeachParty(Action<Chara> action)
6489 {
6490 if (_pts.Count == 0)
6491 {
6492 if (IsPCParty)
6493 {
6494 for (int num8 = EClass.pc.party.members.Count - 1; num8 >= 0; num8--)
6495 {
6496 Chara chara = EClass.pc.party.members[num8];
6497 if (chara == this || chara.host != null || CanSeeLos(chara))
6498 {
6499 _pts.Add(chara);
6500 }
6501 }
6502 }
6503 else
6504 {
6505 for (int num9 = EClass._map.charas.Count - 1; num9 >= 0; num9--)
6506 {
6507 Chara chara2 = EClass._map.charas[num9];
6508 if ((chara2 == this || (chara2.IsFriendOrAbove(this) && CanSeeLos(chara2))) && (chara2 == tc || _pts.Count < 3 || EClass.rnd(_pts.Count * _pts.Count) > 6))
6509 {
6510 _pts.Add(chara2);
6511 }
6512 }
6513 }
6514 }
6515 int num10 = _pts.IndexOf(this);
6516 if (num10 != -1)
6517 {
6518 _pts.RemoveAt(num10);
6519 _pts.Insert(0, this);
6520 }
6521 for (int num11 = _pts.Count - 1; num11 >= 0; num11--)
6522 {
6523 action(_pts[num11]);
6524 }
6525 }
6526 }
6527
6528 public int EvalueRiding()
6529 {
6530 if (ride != null && ride.HasCondition<ConTransmuteBroom>() && HasElement(1417))
6531 {
6532 return 25 + Evalue(226) * 125 / 100;
6533 }
6534 return Evalue(226);
6535 }
6536
6537 public int CalcCastingChance(Element e, int num = 1)
6538 {
6539 if (!(e is Spell))
6540 {
6541 return 100;
6542 }
6543 if (!IsPC)
6544 {
6545 int num2 = 95;
6546 if (host != null)
6547 {
6548 if (host.ride == this)
6549 {
6550 return num2 * 100 / (100 + 300 / Mathf.Max(5, 10 + host.EvalueRiding()));
6551 }
6552 if (host.parasite == this)
6553 {
6554 return num2 * 100 / (100 + 300 / Mathf.Max(5, 10 + host.Evalue(227)));
6555 }
6556 }
6557 return num2;
6558 }
6559 int num3 = Evalue(304);
6560 if (!IsPCFaction)
6561 {
6562 num3 = Mathf.Max(num3, base.LV + 5);
6563 }
6564 int num4 = 0;
6565 int num5 = 0;
6566 bool num6 = GetArmorSkill() == 122;
6567 AttackStyle attackStyle = body.GetAttackStyle();
6568 if (num6)
6569 {
6570 num4 = 20 - Evalue(122) / 5;
6571 num5 += 10 - Evalue(1654) * 4;
6572 }
6573 else
6574 {
6575 num4 = 10 - Evalue(120) / 5;
6576 }
6577 if (num4 < 5)
6578 {
6579 num4 = 5;
6580 }
6581 if (ride != null)
6582 {
6583 num4 += 5;
6584 }
6585 if (parasite != null)
6586 {
6587 num4 += 10;
6588 }
6589 if (attackStyle == AttackStyle.TwoWield)
6590 {
6591 num4 += 5;
6592 }
6593 if (attackStyle == AttackStyle.Shield)
6594 {
6595 num4 += 10;
6596 num5 += 20 - Evalue(1654) * 8;
6597 }
6598 if (isConfused)
6599 {
6600 num4 += 10000;
6601 }
6602 if (HasCondition<ConDim>())
6603 {
6604 num4 += ((Evalue(1654) >= 3) ? 1500 : 2500);
6605 }
6606 if (num > 1)
6607 {
6608 num4 += 5 * num;
6609 }
6610 if (num5 < 0)
6611 {
6612 num5 = 0;
6613 }
6614 return Mathf.Clamp(100 + e.Value - 10 - e.source.LV * e.source.cost[0] * num4 / Mathf.Max(10 + num3 * 10, 1), 0, 100 - num5);
6615 }
6616
6617 public void DoAI(int wait, Action onPerform)
6618 {
6619 SetAI(new DynamicAIAct("", delegate
6620 {
6621 onPerform();
6622 return true;
6623 })
6624 {
6625 wait = wait
6626 });
6627 }
6628
6629 public void Cuddle(Chara c, bool headpat = false)
6630 {
6631 Talk("goodBoy");
6632 Say(headpat ? "headpat" : "cuddle", this, c);
6633 c.ShowEmo(Emo.love);
6634 if (EClass.rnd(IsPC ? 100 : 5000) == 0)
6635 {
6636 c.MakeEgg();
6637 }
6638 if (headpat && this != c)
6639 {
6640 if (c.interest > 0)
6641 {
6642 c.ModAffinity(EClass.pc, 1 + EClass.rnd(3));
6643 c.interest -= 20 + EClass.rnd(10);
6644 }
6646 {
6647 foreach (Chara member in c.party.members)
6648 {
6649 if (!member.IsPC && CanSeeLos(member))
6650 {
6651 member.AddCondition<ConEuphoric>(100 + Evalue(6904) * 5);
6652 }
6653 }
6654 }
6655 }
6656 if (c.Evalue(1221) > 0)
6657 {
6658 int ele = ((c.MainElement == Element.Void) ? 924 : c.MainElement.id);
6659 if (c.id == "hedgehog_ether")
6660 {
6661 ele = 922;
6662 }
6663 Say("reflect_thorne", this, c);
6664 DamageHP(10L, ele, Power, AttackSource.Condition);
6665 }
6666 }
6667
6668 public void Kiss(Chara c)
6669 {
6670 EClass.player.forceTalk = true;
6671 Talk("kiss", null, null, IsPC);
6672 PlaySound("kiss");
6673 renderer.PlayAnime(AnimeID.Kiss, c);
6674 int num = 2 + EClass.rnd(4) + ((!c.IsPC && c.affinity.CurrentStage < Affinity.Stage.Fond) ? (-EClass.rnd(10)) : 0);
6675 c.ShowEmo((num > 0) ? Emo.love : Emo.sad);
6676 if (num > 0 && EClass.rnd(IsPC ? 100 : 5000) == 0)
6677 {
6678 c.MakeEgg();
6679 }
6680 if (IsPC && this != c)
6681 {
6682 if (c.interest > 0)
6683 {
6684 c.ModAffinity(EClass.pc, num);
6685 c.interest -= 20 + EClass.rnd(10);
6686 }
6687 else
6688 {
6689 c.Say("affinityNone", c, EClass.pc);
6690 }
6691 }
6692 Effect.Get("love")._Play(pos, isSynced ? renderer.position : pos.Position(), 0f, c.pos);
6693 }
6694
6695 public void Slap(Chara c, bool slapToDeath = false)
6696 {
6697 if (id == "olderyoungersister")
6698 {
6700 }
6701 PlaySound("whip");
6702 Say("slap", this, c);
6703 c.PlayAnime(AnimeID.Shiver);
6704 c.DamageHP(slapToDeath ? (c.MaxHP * 2) : (5 + EClass.rndHalf(EClass.pc.MaxHP / 3)), 919, 100, AttackSource.Condition);
6705 c.OnInsulted();
6706 if (slapToDeath && c.IsAliveInCurrentZone)
6707 {
6708 c.Die();
6709 }
6710 }
6711
6712 public Chara SetEnemy(Chara c = null)
6713 {
6714 enemy = c;
6715 if (c == null)
6716 {
6717 if (ai is GoalCombat)
6718 {
6719 ai.Cancel();
6720 }
6721 }
6722 else
6723 {
6724 calmCheckTurn = 10 + EClass.rnd(30);
6725 }
6726 return c;
6727 }
6728
6729 public void TrySetEnemy(Chara c)
6730 {
6731 if ((!IsPC || !EClass.game.config.autoCombat.bDontChangeTarget) && (enemy == null || (EClass.rnd(5) == 0 && Dist(c) <= 1)) && ((!IsPCFaction && !IsPCFactionMinion) || (!c.IsPCFaction && !c.IsPCFactionMinion)) && (hostility != Hostility.Enemy || c.hostility != Hostility.Enemy) && (!c.IsPC || hostility < Hostility.Neutral))
6732 {
6733 SetEnemy(c);
6734 }
6735 }
6736
6737 public void GoHostile(Card _tg)
6738 {
6739 if (enemy == null && !IsPC)
6740 {
6741 if (GetInt(106) == 0)
6742 {
6743 TalkTopic("aggro");
6744 }
6745 if (OriginalHostility != Hostility.Enemy)
6746 {
6747 ShowEmo(Emo.angry);
6748 }
6749 SetEnemy(_tg.Chara);
6750 }
6751 if (!IsPCFaction && !IsPCFactionMinion && (_tg.IsPCFaction || _tg.IsPCFactionMinion))
6752 {
6753 if (hostility >= Hostility.Neutral)
6754 {
6755 Say("angry", this);
6756 }
6757 hostility = Hostility.Enemy;
6758 }
6759 }
6760
6761 public void DoHostileAction(Card _tg, bool immediate = false)
6762 {
6763 if (_tg == null || !_tg.isChara)
6764 {
6765 return;
6766 }
6767 Chara chara = _tg.Chara;
6768 if (chara.IsPC)
6769 {
6770 EClass.pc.combatCount = 10;
6771 }
6772 if (!chara.IsAliveInCurrentZone || !IsAliveInCurrentZone || chara == this)
6773 {
6774 return;
6775 }
6776 if ((IsPCFaction || IsPCFactionMinion) && (chara.IsPCFaction || chara.IsPCFactionMinion))
6777 {
6778 chara.Say("frown", this, chara);
6779 }
6780 else
6781 {
6782 if (EClass._zone.IsRegion)
6783 {
6784 return;
6785 }
6786 if (IsPC)
6787 {
6788 if (chara.IsFriendOrAbove() && !immediate)
6789 {
6790 chara.Say("frown", this, chara);
6791 chara.ShowEmo(Emo.sad);
6792 chara.hostility = Hostility.Neutral;
6793 return;
6794 }
6795 if (!chara.IsPCFaction && chara.hostility >= Hostility.Neutral && !EClass._zone.IsPCFaction)
6796 {
6797 bool flag = chara.id == "fanatic";
6798 if (EClass.rnd(4) == 0 || flag)
6799 {
6800 chara.Say("callHelp", chara);
6801 chara.CallHelp(this, flag);
6802 }
6803 }
6804 if (chara.hostility <= Hostility.Enemy)
6805 {
6806 foreach (Chara member in EClass.pc.party.members)
6807 {
6808 if (member != EClass.pc && member.enemy == null && member.CanSee(chara))
6809 {
6810 member.SetEnemy(chara);
6811 }
6812 }
6813 }
6814 }
6815 else if (chara.IsPC && hostility <= Hostility.Enemy)
6816 {
6817 foreach (Chara member2 in EClass.pc.party.members)
6818 {
6819 if (member2 != EClass.pc && member2.enemy == null && member2.CanSee(this))
6820 {
6821 member2.SetEnemy(this);
6822 }
6823 }
6824 }
6825 if (chara.calmCheckTurn <= 0 || IsPC)
6826 {
6827 chara.calmCheckTurn = (IsPC ? (20 + EClass.rnd(30)) : (10 + EClass.rnd(10)));
6828 }
6829 if (hostility != Hostility.Enemy || chara.hostility != Hostility.Enemy)
6830 {
6831 GoHostile(chara);
6832 chara.GoHostile(this);
6833 if (base.isHidden && !chara.CanSee(this) && !chara.IsDisabled && !chara.IsPCParty && !chara.IsPCPartyMinion && EClass.rnd(10 + Dist(chara) * 10) == 0)
6834 {
6835 Thing t = ThingGen.Create("49");
6836 ActThrow.Throw(chara, pos, t);
6837 Act.TC = chara;
6838 }
6839 }
6840 }
6841 }
6842
6843 public void CallHelp(Chara tg, bool fanatic = false)
6844 {
6845 foreach (Chara chara in EClass._map.charas)
6846 {
6847 if (!chara.IsPCFaction && chara.OriginalHostility == OriginalHostility && (fanatic || Dist(chara) <= 6) && (EClass.rnd(3) != 0 || fanatic))
6848 {
6849 chara.GoHostile(tg);
6850 }
6851 }
6852 }
6853
6854 public bool FindNewEnemy()
6855 {
6856 if (EClass._zone.isPeace && base.IsPCFactionOrMinion && !IsPC)
6857 {
6858 return false;
6859 }
6860 if (enemy != null && !enemy.IsAliveInCurrentZone)
6861 {
6862 enemy = null;
6863 }
6864 if (enemy != null)
6865 {
6866 return false;
6867 }
6868 if (IsPCParty && EClass.pc.isHidden && base.isHidden)
6869 {
6870 return false;
6871 }
6872 if (mimicry != null && mimicry.IsThing)
6873 {
6874 return false;
6875 }
6876 if (!base.IsPCFactionOrMinion && OriginalHostility == Hostility.Neutral && !(trait is TraitGuard) && id != "unicorn")
6877 {
6878 return false;
6879 }
6880 bool flag = enemy != null || ai is GoalCombat;
6881 int num = (base.PER + Evalue(210) * 2) * ((!flag) ? 1 : 2);
6882 bool flag2 = IsPCParty && !IsPC && EClass.game.config.tactics.dontWander;
6883 bool flag3 = !IsPCParty;
6884 Chara chara = null;
6885 int num2 = 9999;
6886 for (int i = 0; i < EClass._map.charas.Count; i++)
6887 {
6888 Chara chara2 = EClass._map.charas[i];
6889 if (chara2 == this || !IsHostile(chara2) || !CanSee(chara2) || (chara2.mimicry != null && chara2.mimicry.IsThing))
6890 {
6891 continue;
6892 }
6893 int num3 = Dist(chara2);
6894 int num4 = GetSightRadius() + (flag ? 1 : 0);
6895 if (num3 > num4)
6896 {
6897 continue;
6898 }
6899 if (flag3 && EClass.rnd(chara2.Evalue(152) + 5) * (100 + num3 * num3 * 10) / 100 > EClass.rnd(num))
6900 {
6901 if (this == pos.FirstChara)
6902 {
6903 chara2.ModExp(152, Mathf.Clamp((num - chara2.Evalue(152)) / 2, 1, Mathf.Max(30 - stealthSeen * 2, 1)));
6904 }
6905 stealthSeen++;
6906 }
6907 else if (CanSeeLos(chara2) && (!flag2 || EClass.pc.isBlind || EClass.pc.CanSeeLos(chara2)) && (!base.IsPCFactionOrMinion || EClass.pc.ai.ShouldAllyAttack(chara2)))
6908 {
6909 if (!IsPCParty)
6910 {
6911 DoHostileAction(chara2);
6912 enemy = chara2;
6913 return true;
6914 }
6915 if (num3 < num2)
6916 {
6917 num2 = num3;
6918 chara = chara2;
6919 }
6920 }
6921 }
6922 if (chara != null)
6923 {
6924 DoHostileAction(chara);
6925 enemy = chara;
6926 return true;
6927 }
6928 return false;
6929 }
6930
6932 {
6933 for (int i = 0; i < EClass._map.charas.Count; i++)
6934 {
6935 Chara chara = EClass._map.charas[i];
6936 if (chara != this && chara != enemy && (chara.mimicry == null || !chara.mimicry.IsThing) && IsHostile(chara) && Dist(chara) <= 1 && CanInteractTo(chara.pos))
6937 {
6938 DoHostileAction(chara);
6939 enemy = chara;
6940 return true;
6941 }
6942 }
6943 return false;
6944 }
6945
6946 public bool IsHostile()
6947 {
6948 return hostility <= Hostility.Enemy;
6949 }
6950
6951 public bool IsHostile(Chara c)
6952 {
6953 if (c == null)
6954 {
6955 return false;
6956 }
6957 if (base.IsPCFactionOrMinion)
6958 {
6959 if ((c == EClass.pc.enemy && !c.IsPCFactionOrMinion) || c.hostility <= Hostility.Enemy)
6960 {
6961 return true;
6962 }
6963 }
6964 else
6965 {
6966 if (trait is TraitGuard && c.IsPCParty && EClass.player.IsCriminal && EClass._zone.instance == null)
6967 {
6968 return true;
6969 }
6970 if (OriginalHostility >= Hostility.Friend)
6971 {
6972 if (hostility <= Hostility.Enemy && c.IsPCFactionOrMinion)
6973 {
6974 return true;
6975 }
6976 if (c.hostility <= Hostility.Enemy && c.OriginalHostility == Hostility.Enemy)
6977 {
6978 return true;
6979 }
6980 }
6981 else if (OriginalHostility <= Hostility.Enemy && (c.IsPCFactionOrMinion || (c.OriginalHostility != Hostility.Enemy && c.hostility >= Hostility.Friend)))
6982 {
6983 return true;
6984 }
6985 }
6986 if (id == "unicorn" && (Evalue(418) < 0 || (c.HasElement(1216) && c.Evalue(418) < 1)))
6987 {
6988 return true;
6989 }
6990 return false;
6991 }
6992
6993 public bool IsNeutral()
6994 {
6995 return hostility == Hostility.Neutral;
6996 }
6997
6998 public bool IsNeutralOrAbove()
6999 {
7000 return hostility >= Hostility.Neutral;
7001 }
7002
7003 public bool IsBranchMember()
7004 {
7005 if (faction == EClass.Home)
7006 {
7007 return homeZone == EClass.game.activeZone;
7008 }
7009 return false;
7010 }
7011
7012 public bool IsHomeMember()
7013 {
7014 return faction == EClass.Home;
7015 }
7016
7017 public bool IsInHomeZone()
7018 {
7019 return EClass.game.activeZone == currentZone;
7020 }
7021
7022 public bool IsInSpot<T>() where T : TraitSpot
7023 {
7024 foreach (T item in EClass._map.props.installed.traits.List<T>())
7025 {
7026 foreach (Point item2 in item.ListPoints())
7027 {
7028 if (pos.Equals(item2))
7029 {
7030 return true;
7031 }
7032 }
7033 }
7034 return false;
7035 }
7036
7037 public bool IsGuest()
7038 {
7039 return memberType == FactionMemberType.Guest;
7040 }
7041
7042 public bool IsFriendOrAbove()
7043 {
7044 return hostility >= Hostility.Friend;
7045 }
7046
7047 public bool IsFriendOrAbove(Chara c)
7048 {
7049 if (base.IsPCFactionOrMinion || IsFriendOrAbove())
7050 {
7052 {
7053 return true;
7054 }
7055 }
7056 else if (IsHostile() && c.IsHostile())
7057 {
7058 return true;
7059 }
7060 return false;
7061 }
7062
7064 {
7065 CardRenderer cardRenderer = renderer;
7066 CharaRenderer charaRenderer = new CharaRenderer();
7067 if (source.skinAntiSpider != 0)
7068 {
7069 base.idSkin = (EClass.core.config.game.antiSpider ? source.skinAntiSpider : 0);
7070 }
7071 if (host != null)
7072 {
7073 charaRenderer.pccData = PCCData.Create("ride");
7074 string idPart = base.c_idRidePCC.IsEmpty(EClass.core.pccs.sets["ride"].map["body"].map.Keys.First());
7075 charaRenderer.pccData.SetPart("body", "ride", idPart);
7076 charaRenderer.pccData.ride = EClass.core.pccs.GetRideData(idPart);
7077 }
7078 else
7079 {
7080 foreach (Condition condition in conditions)
7081 {
7082 RendererReplacer rendererReplacer = condition.GetRendererReplacer();
7083 if (rendererReplacer != null)
7084 {
7085 charaRenderer.replacer = rendererReplacer;
7086 charaRenderer.data = rendererReplacer.data;
7087 charaRenderer.pccData = rendererReplacer.pccData;
7088 break;
7089 }
7090 }
7091 if (charaRenderer.replacer == null)
7092 {
7093 charaRenderer.pccData = pccData;
7094 }
7095 }
7096 renderer = charaRenderer;
7097 renderer.SetOwner(this);
7098 if (cardRenderer != null)
7099 {
7100 renderer.SetFirst(first: false, cardRenderer.position);
7101 }
7102 return charaRenderer;
7103 }
7104
7105 public void SetPCCState(PCCState state)
7106 {
7107 if (IsPCC)
7108 {
7109 PCC.Get(pccData).Build(state);
7110 }
7111 }
7112
7113 public override Sprite GetSprite(int dir = 0)
7114 {
7115 string str = GetStr("sprite_override");
7116 if (!str.IsEmpty())
7117 {
7118 Sprite sprite = ModUtil.LoadSprite(str);
7119 if ((bool)sprite)
7120 {
7121 return sprite;
7122 }
7123 }
7124 if (IsPCC)
7125 {
7126 PCC pCC = PCC.Get(pccData);
7127 pCC.Build();
7128 return pCC.variation.idle[0, 0];
7129 }
7130 bool snow = EClass.core.IsGameStarted && EClass._zone.IsSnowCovered;
7131 int skin = 0;
7132 if (spriteReplacer?.data != null)
7133 {
7134 Sprite sprite2 = spriteReplacer.GetSprite(dir, skin, snow);
7135 if ((bool)sprite2)
7136 {
7137 return sprite2;
7138 }
7139 }
7140 if (sourceCard.tiles.Length > 1)
7141 {
7142 skin = ((base.idSkin == 0 && !source.staticSkin) ? (base.uid % sourceCard.tiles.Length / 2 * 2 + ((!base.IsMale) ? 1 : 0)) : base.idSkin);
7143 }
7144 return sourceCard.GetSprite(dir, skin, snow);
7145 }
7146
7147 public void SetTempHand(int right = 0, int left = 0)
7148 {
7149 if (IsPC && !IsPC)
7150 {
7151 pccData.tempRight = EClass.scene.screenElin.renderTempEQ.ConvertTile(right);
7152 pccData.tempLeft = EClass.scene.screenElin.renderTempEQ.ConvertTile(left);
7153 }
7154 }
7155
7156 public override SubPassData GetSubPassData()
7157 {
7158 if (IsPCC)
7159 {
7160 if (IsDeadOrSleeping || (!EClass.player.altHeldPos && parent is Chara))
7161 {
7163 }
7164 }
7165 else if (conSleep != null && host == null && pos.Equals(EClass.pc.pos) && IsHuman && (GetBool(123) || affinity.CanSleepBeside()))
7166 {
7167 return EClass.setting.pass.subDead;
7168 }
7169 return SubPassData.Default;
7170 }
7171
7172 public override void SetRenderParam(RenderParam p)
7173 {
7174 p.mat = base.material;
7175 p.matColor = base.colorInt;
7176 if (!renderer.usePass)
7177 {
7178 return;
7179 }
7180 if (renderer.replacer != null)
7181 {
7182 p.tile = renderer.replacer.tile * ((!flipX) ? 1 : (-1));
7183 if (renderer.replacer.mat != -1)
7184 {
7185 p.mat = EClass.sources.materials.rows.TryGet(renderer.replacer.mat, 0);
7186 p.matColor = BaseTileMap.GetColorInt(ref p.mat.matColor, 100);
7187 p.color -= 1048576f;
7188 }
7189 }
7190 else if (source._tiles_snow.Length != 0 && EClass._zone.IsSnowCovered)
7191 {
7192 if (source._tiles_snow.Length > 1)
7193 {
7194 int num = ((base.idSkin != 0 || source.staticSkin) ? base.idSkin : (base.uid % source._tiles_snow.Length / 2 * 2 + ((!base.IsMale) ? 1 : 0)));
7195 if (num < 0)
7196 {
7197 num = 0;
7198 }
7199 p.tile = source._tiles_snow[(num < source._tiles_snow.Length) ? num : 0] * ((!flipX) ? 1 : (-1));
7200 }
7201 else
7202 {
7203 p.tile = source._tiles_snow[0] * ((!flipX) ? 1 : (-1));
7204 }
7205 }
7206 else if (sourceCard._tiles.Length > 1)
7207 {
7208 int num2 = ((base.idSkin != 0 || source.staticSkin) ? base.idSkin : (base.uid % sourceCard._tiles.Length / 2 * 2 + ((!base.IsMale) ? 1 : 0)));
7209 if (num2 < 0)
7210 {
7211 num2 = 0;
7212 }
7213 p.tile = sourceCard._tiles[(num2 >= 0 && num2 < sourceCard._tiles.Length) ? num2 : 0] * ((!flipX) ? 1 : (-1));
7214 }
7215 else
7216 {
7217 p.tile = sourceCard._tiles[0] * ((!flipX) ? 1 : (-1));
7218 }
7219 p.dir = base.dir;
7220 }
7221
7222 public override string GetHoverText()
7223 {
7224 if (mimicry != null && mimicry.IsThing)
7225 {
7226 return mimicry.GetHoverText();
7227 }
7228 string text = ((mimicry != null && mimicry.Card != this) ? mimicry.GetName(NameStyle.Full) : base.Name);
7229 if (IsFriendOrAbove())
7230 {
7231 text = text.TagColor(EClass.Colors.colorFriend);
7232 }
7233 else if (IsHostile())
7234 {
7235 text = text.TagColor(EClass.Colors.colorHostile);
7236 }
7237 int num = 2;
7238 int lV = EClass.pc.LV;
7239 if (base.LV >= lV * 5)
7240 {
7241 num = 0;
7242 }
7243 else if (base.LV >= lV * 2)
7244 {
7245 num = 1;
7246 }
7247 else if (base.LV <= lV / 4)
7248 {
7249 num = 4;
7250 }
7251 else if (base.LV <= lV / 2)
7252 {
7253 num = 3;
7254 }
7255 string text2 = Lang.GetList("lvComparison")[num];
7256 text2 = (" (" + text2 + ") ").TagSize(14).TagColor(EClass.Colors.gradientLVComparison.Evaluate(0.25f * (float)num));
7257 string s = (IsFriendOrAbove() ? "HostilityAlly" : (IsNeutral() ? "HostilityNeutral" : "HostilityEnemy"));
7258 s = (" (" + s.lang() + ") ").TagSize(14);
7259 s = "";
7260 if (memberType == FactionMemberType.Guest)
7261 {
7262 s += (" (" + "guest".lang() + ") ").TagSize(14);
7263 }
7264 else if (memberType == FactionMemberType.Livestock)
7265 {
7266 s += (" (" + "livestock".lang() + ") ").TagSize(14);
7267 }
7268 if (!EClass.pc.IsMoving)
7269 {
7270 if (EClass.pc.HasHigherGround(this))
7271 {
7272 text2 += "lowerGround".lang();
7273 }
7274 else if (HasHigherGround(EClass.pc))
7275 {
7276 text2 += "higherGround".lang();
7277 }
7278 }
7279 if (Evalue(1232) > 0)
7280 {
7281 text2 = "milkBaby".lang().TagSize(14) + text2;
7282 }
7283 if (Guild.Fighter.ShowBounty(this) && Guild.Fighter.HasBounty(this))
7284 {
7285 text2 = "hasBounty".lang().TagSize(14) + text2;
7286 }
7287 if (EClass.pc.HasElement(481))
7288 {
7289 text2 += ("(" + faith.Name + ")").TagSize(14);
7290 }
7291 if (EClass.pc.HasElement(6607))
7292 {
7293 s += CraftUtil.GetBloodText(this).TagSize(14).TagColor(EClass.Colors.colorBlood);
7294 }
7295 return text + text2 + s;
7296 }
7297
7298 public override string GetHoverText2()
7299 {
7300 if (mimicry != null && mimicry.IsThing)
7301 {
7302 return mimicry.GetHoverText2();
7303 }
7304 string text = "";
7305 if (knowFav)
7306 {
7307 text += Environment.NewLine;
7308 text = text + "<size=14>" + "favgift".lang(GetFavCat().GetName().ToLower(), GetFavFood().GetName()) + "</size>";
7309 }
7310 string text2 = "";
7312 {
7313 text2 += Environment.NewLine;
7314 text2 = text2 + "Lv:" + base.LV + " HP:" + base.hp + "/" + MaxHP + " MP:" + mana.value + "/" + mana.max + " DV:" + DV + " PV:" + PV + " Hunger:" + hunger.value;
7315 text2 += Environment.NewLine;
7316 text2 = text2 + "Global:" + IsGlobal + " AI:" + ai?.ToString() + " " + source.tactics.IsEmpty(EClass.sources.tactics.map.TryGetValue(id)?.id ?? EClass.sources.tactics.map.TryGetValue(job.id)?.id ?? "predator");
7317 text2 += Environment.NewLine;
7318 text2 = text2 + base.uid + IsMinion + "/" + base.c_uidMaster + "/" + master;
7319 text2 = text2 + " dir:" + base.dir + " skin:" + base.idSkin + " scaled:" + base.isScaled;
7320 }
7321 if (EClass.pc.held?.trait is TraitWhipLove && IsPCFaction)
7322 {
7323 text2 += Environment.NewLine;
7324 text2 += "<size=14>";
7325 foreach (Hobby item in ListWorks())
7326 {
7327 text2 = text2 + item.Name + ", ";
7328 }
7329 foreach (Hobby item2 in ListHobbies())
7330 {
7331 text2 = text2 + item2.Name + ", ";
7332 }
7333 text2 = text2.TrimEnd(", ".ToCharArray()) + "</size>";
7334 }
7335 string text3 = "";
7336 IEnumerable<BaseStats> enumerable = conditions.Concat((!IsPCFaction) ? new BaseStats[0] : new BaseStats[2] { hunger, stamina });
7337 if (enumerable.Count() > 0)
7338 {
7339 text3 += Environment.NewLine;
7340 text3 += "<size=14>";
7341 int num = 0;
7342 foreach (BaseStats item3 in enumerable)
7343 {
7344 if (item3 is ConBaseTransmuteMimic)
7345 {
7346 continue;
7347 }
7348 string text4 = item3.GetPhaseStr();
7349 if (text4.IsEmpty() || text4 == "#")
7350 {
7351 continue;
7352 }
7353 Color c = Color.white;
7354 switch (item3.source.group)
7355 {
7356 case "Bad":
7357 case "Debuff":
7358 case "Disease":
7360 break;
7361 case "Buff":
7363 break;
7364 }
7366 {
7367 text4 = text4 + "(" + item3.GetValue() + ")";
7368 if (resistCon != null && resistCon.ContainsKey(item3.id))
7369 {
7370 text4 = text4 + "{" + resistCon[item3.id] + "}";
7371 }
7372 }
7373 num++;
7374 text3 = text3 + text4.TagColor(c) + ", ";
7375 }
7376 if (num == 0)
7377 {
7378 text3 = "";
7379 }
7380 else
7381 {
7382 text = "";
7383 text3 = text3.TrimEnd(", ".ToCharArray()) + "</size>";
7384 }
7385 }
7387 {
7388 text3 += Environment.NewLine;
7389 foreach (ActList.Item item4 in ability.list.items)
7390 {
7391 text3 = text3 + item4.act.Name + ", ";
7392 }
7393 text3 = text3.TrimEnd(", ".ToCharArray());
7394 }
7395 return text + text2 + text3;
7396 }
7397
7398 public string GetTopicText(string topic = "calm")
7399 {
7400 ConTransmuteHuman condition = GetCondition<ConTransmuteHuman>();
7401 string key = ((condition == null) ? source : condition.chara.source).idText.IsEmpty((condition == null) ? id : condition.chara.id);
7402 if (id == "littleOne" && EClass._zone is Zone_LittleGarden)
7403 {
7404 key = "littleOne2";
7405 }
7406 SourceCharaText.Row row = EClass.sources.charaText.map.TryGetValue(key);
7407 if (row == null)
7408 {
7409 return null;
7410 }
7411 string text = row.GetText(topic, returnNull: true);
7412 if (text.IsEmpty())
7413 {
7414 return null;
7415 }
7416 if (text.StartsWith("@"))
7417 {
7418 row = EClass.sources.charaText.map.TryGetValue(text.Replace("@", ""));
7419 if (row == null)
7420 {
7421 return null;
7422 }
7423 text = row.GetText(topic, returnNull: true);
7424 if (text.IsEmpty())
7425 {
7426 return null;
7427 }
7428 }
7429 return text.Split(Environment.NewLine.ToCharArray()).RandomItem();
7430 }
7431
7432 public string TalkTopic(string topic = "calm")
7433 {
7434 if (host == null && !IsInActiveZone)
7435 {
7436 return null;
7437 }
7438 if (!isSynced && (host == null || !host.isSynced) && topic != "dead")
7439 {
7440 return null;
7441 }
7442 if (IsPCParty)
7443 {
7444 int num = EClass.pc.party.members.Count - 1;
7445 switch (topic)
7446 {
7447 case "calm":
7448 if (EClass.rnd(num * 5) != 0)
7449 {
7450 return null;
7451 }
7452 break;
7453 case "aggro":
7454 if (EClass.rnd(num * 10) != 0)
7455 {
7456 return null;
7457 }
7458 break;
7459 case "kill":
7460 if (EClass.rnd(num * 3) != 0)
7461 {
7462 return null;
7463 }
7464 break;
7465 case "fov":
7466 return null;
7467 }
7468 }
7469 string topicText = GetTopicText(topic);
7470 if (topicText.IsEmpty())
7471 {
7472 return null;
7473 }
7474 HashSet<string> obj = new HashSet<string>
7475 {
7476 "_bracketTalk".lang(),
7477 "\"",
7478 "“",
7479 "「"
7480 };
7481 bool flag = topicText.StartsWith("*");
7482 bool flag2 = topicText.StartsWith("(");
7483 bool flag3 = obj.Any(topicText.StartsWith);
7484 topicText = ApplyTone(topicText);
7485 topicText = topicText.Replace('~', '*');
7486 Msg.SetColor(flag2 ? Msg.colors.Thinking : (flag3 ? Msg.colors.Talk : Msg.colors.Ono));
7487 Msg.Say(StripTalkSpecialCharacters(topicText.Replace("&", "")));
7488 if (topic == "dead")
7489 {
7490 EClass.ui.popGame.PopText(ApplyNewLine(topicText.StripBrackets()), null, "PopTextDead", default(Color), pos.Position() + EClass.setting.render.tc.textPosDead);
7491 }
7492 else if (flag || flag3 || flag2)
7493 {
7494 (host ?? this).renderer.Say(ApplyNewLine(topicText.StripBrackets()), default(Color), IsPCParty ? 0.6f : 0f);
7495 }
7496 return topicText;
7497 }
7498
7499 public override Sprite GetImageSprite()
7500 {
7501 return GetSprite();
7502 }
7503
7505 {
7506 memberType = type;
7507 }
7508
7509 public void ShowDialog()
7510 {
7511 Zone_Nymelle zone_Nymelle = EClass._zone as Zone_Nymelle;
7512 if (conSuspend != null && IsPCParty)
7513 {
7514 RemoveCondition<ConSuspend>();
7515 }
7516 if (LayerDrama.forceJump == null)
7517 {
7518 if (IsDeadOrSleeping)
7519 {
7520 ShowDialog("_chara", "sleep");
7521 return;
7522 }
7523 if (EClass.pc.isHidden && !CanSee(EClass.pc))
7524 {
7525 ShowDialog("_chara", "invisible");
7526 return;
7527 }
7528 if (!IsPC && !EClass.player.codex.DroppedCard(id) && affinity.CanGiveCard())
7529 {
7531 ShowDialog("_chara", "give_card");
7532 Thing thing = ThingGen.Create("figure");
7533 thing.MakeFigureFrom(id);
7534 EClass.player.DropReward(thing);
7535 thing = ThingGen.Create("figure3");
7536 thing.MakeFigureFrom(id);
7537 EClass.player.DropReward(thing);
7538 return;
7539 }
7540 if (GetInt(71) == -2)
7541 {
7542 ShowDialog("_chara", "give_lunch");
7543 Thing t = CraftUtil.MakeLoveLunch(this);
7545 SetInt(71, EClass.world.date.GetRaw() + 43200);
7546 return;
7547 }
7548 if (base.isRestrained)
7549 {
7550 ShowDialog("_chara", "strain");
7551 return;
7552 }
7553 if (IsEscorted())
7554 {
7555 ShowDialog("_chara", "escort");
7556 return;
7557 }
7559 {
7560 string step = ((!(EClass._zone is Zone_Wedding)) ? "party" : (IsPCParty ? "wedding_love" : ((IsMarried || affinity.IsWeddingHater) ? "wedding_hater" : "wedding")));
7561 if (EClass._zone is Zone_Wedding && IsPCParty && base.c_love != null && !base.c_love.gaveCutter)
7562 {
7563 step = "wedding_cutter";
7564 EClass.player.DropReward(ThingGen.Create("dagger_cakecutter"));
7565 base.c_love.gaveCutter = true;
7566 }
7567 ShowDialog("_chara", step);
7568 return;
7569 }
7570 if (EClass.game.quests.OnShowDialog(this))
7571 {
7572 return;
7573 }
7574 if (id == "nino")
7575 {
7577 }
7578 switch (id)
7579 {
7580 case "loytel":
7581 {
7583 {
7584 EClass.game.quests.Get("pre_debt_runaway").Complete();
7585 EClass.player.flags.loytelEscaped = false;
7586 EClass.game.quests.Add("debt", "loytel");
7587 ShowDialog("loytel", "loytelEscaped");
7588 return;
7589 }
7590 QuestDebt questDebt = EClass.game.quests.Get<QuestDebt>();
7591 if (questDebt != null && questDebt.paid)
7592 {
7593 questDebt.stage++;
7594 if (questDebt.stage > 7)
7595 {
7596 questDebt.stage = 7;
7597 }
7598 ShowDialog("loytel", "debt" + questDebt.stage);
7599 return;
7600 }
7601 break;
7602 }
7603 case "farris":
7604 if (EClass._zone.id == "startVillage" || EClass._zone.id == "startVillage3" || EClass.game.IsSurvival)
7605 {
7606 ShowDialog("farris");
7607 return;
7608 }
7610 {
7611 case -1:
7612 ShowDialog("farris", "nymelle_noQuest");
7613 break;
7614 case 0:
7615 ShowDialog("farris", "nymelle_first");
7616 break;
7617 case 1:
7618 ShowDialog("farris", "home_first");
7619 break;
7620 default:
7621 ShowDialog("farris");
7622 break;
7623 }
7624 return;
7625 case "ashland":
7626 ShowDialog("ashland");
7627 return;
7628 case "fiama":
7629 if (zone_Nymelle != null && zone_Nymelle.IsCrystalLv && EClass.game.quests.GetPhase<QuestExploration>() == 3)
7630 {
7631 SoundManager.ForceBGM();
7632 LayerDrama.ActivateMain("mono", "nymelle_crystal");
7633 }
7635 {
7637 {
7638 EClass.player.flags.fiamaFirstDream = true;
7639 ShowDialog("fiama", "firstDream");
7640 }
7642 {
7643 ShowDialog("fiama", "giveStoryBook").SetOnKill(delegate
7644 {
7645 EClass.player.flags.fiamaStoryBookGiven = true;
7646 EClass.player.DropReward(ThingGen.Create("book_story"));
7647 });
7648 }
7649 else
7650 {
7651 ShowDialog("fiama");
7652 }
7653 }
7654 else
7655 {
7656 ShowDialog("fiama");
7657 }
7658 return;
7659 case "big_sister":
7661 {
7662 ShowDialog("big_sister", "little_saved");
7663 EClass.player.flags.little_saved = false;
7664 return;
7665 }
7667 {
7668 ShowDialog("big_sister", "little_dead");
7669 EClass.player.flags.little_killed = false;
7670 return;
7671 }
7672 break;
7673 }
7674 if (trait is TraitGuildDoorman)
7675 {
7676 string tag = ((trait is TraitDoorman_Fighter) ? "fighter" : ((trait is TraitDoorman_Mage) ? "mage" : "thief"));
7677 ShowDialog("guild_doorman", "main", tag);
7678 return;
7679 }
7680 if (trait is TraitGuildClerk)
7681 {
7682 string tag2 = ((trait is TraitClerk_Fighter) ? "fighter" : ((trait is TraitClerk_Mage) ? "mage" : "thief"));
7683 ShowDialog("guild_clerk", "main", tag2);
7684 return;
7685 }
7686 }
7687 bool flag = true;
7688 if (id == "parttimer_jure" && (!EClass._zone.IsFestival || !(EClass._zone is Zone_Noyel) || EClass.pc.faith == EClass.game.religions.Healing))
7689 {
7690 flag = false;
7691 }
7692 string book = "_chara";
7693 if (flag)
7694 {
7695 string text = GetStr("drama_override").IsEmpty(id);
7696 if (File.Exists(PackageIterator.GetFiles("Dialog/Drama/" + text + ".xlsx").LastOrDefault()?.FullName ?? (CorePath.DramaData + id + ".xlsx")))
7697 {
7698 book = text;
7699 }
7700 }
7701 ShowDialog(book);
7702 }
7703
7704 public LayerDrama ShowDialog(string book, string step = "main", string tag = "")
7705 {
7706 return _ShowDialog(book, null, step, tag);
7707 }
7708
7709 private LayerDrama _ShowDialog(string book, string sheet, string step = "main", string tag = "")
7710 {
7711 EClass.Sound.Play("pop_drama");
7712 if (book == "_chara" && IsPC)
7713 {
7714 step = "pc";
7715 }
7716 if (id == "lomias")
7717 {
7719 }
7720 return LayerDrama.Activate(book, sheet, step, this, null, tag);
7721 }
7722
7724 {
7725 return (ai.IsRunning ? ai.GetDestination() : pos).Copy();
7726 }
7727
7728 public int GetHireCost()
7729 {
7730 return base.LV / 2 + 4;
7731 }
7732
7733 public int GetHappiness()
7734 {
7735 int num = 50;
7736 if (FindBed() != null)
7737 {
7738 num += 50;
7739 }
7740 return num;
7741 }
7742
7743 public string GetTextHappiness()
7744 {
7745 return GetHappiness().ToString() ?? "";
7746 }
7747
7748 public string GetActionText()
7749 {
7750 string result = "?????";
7751 if (ai != null)
7752 {
7753 result = ai.GetCurrentActionText();
7754 }
7755 return result;
7756 }
7757
7758 public override void WriteNote(UINote n, Action<UINote> onWriteNote = null, IInspect.NoteMode mode = IInspect.NoteMode.Default, Recipe recipe = null)
7759 {
7760 n.Clear();
7761 UIItem uIItem = n.AddHeaderCard(base.Name.ToTitleCase());
7762 SetImage(uIItem.image2);
7763 uIItem.text2.SetText(race.GetText().ToTitleCase(wholeText: true) + " " + job.GetText().ToTitleCase(wholeText: true));
7764 n.AddText("");
7765 n.Build();
7766 }
7767
7769 {
7770 switch (m)
7771 {
7772 case UIList.SortMode.ByJob:
7773 sortVal = job._index * 10000 + sourceCard._index;
7774 break;
7775 case UIList.SortMode.ByRace:
7776 sortVal = race._index * 10000 * ((!IsHuman) ? 1 : (-1)) + sourceCard._index;
7777 break;
7778 case UIList.SortMode.ByFeat:
7779 sortVal = -GetTotalFeat();
7780 break;
7781 case UIList.SortMode.ByPartyOrder:
7782 sortVal = EClass.pc.party.members.IndexOf(this);
7783 return;
7784 default:
7785 sortVal = sourceCard._index * ((!IsHuman) ? 1 : (-1));
7786 break;
7787 case UIList.SortMode.ByWorkk:
7788 break;
7789 }
7790 if (base.isFav)
7791 {
7792 sortVal -= 100000000;
7793 }
7794 }
7795
7796 public void ClearBed(Map map = null)
7797 {
7798 if (map == null)
7799 {
7800 map = EClass._map;
7801 }
7802 foreach (Card item in map.props.installed.all)
7803 {
7804 if (item.trait is TraitBed traitBed && traitBed.IsHolder(this))
7805 {
7806 traitBed.RemoveHolder(this);
7807 }
7808 }
7809 }
7810
7812 {
7813 foreach (Card item in EClass._map.props.installed.all)
7814 {
7815 if (item.trait is TraitBed traitBed && traitBed.IsHolder(this))
7816 {
7817 return traitBed;
7818 }
7819 }
7820 return null;
7821 }
7822
7824 {
7825 if (!IsPCFaction && !IsGuest())
7826 {
7827 return null;
7828 }
7829 foreach (Card item in EClass._map.props.installed.all)
7830 {
7831 if (item.trait is TraitBed traitBed && traitBed.CanAssign(this))
7832 {
7833 traitBed.AddHolder(this);
7834 Msg.Say("claimBed", this);
7835 return traitBed;
7836 }
7837 }
7838 return null;
7839 }
7840
7841 public void TryPutSharedItems(IEnumerable<Thing> containers, bool msg = true)
7842 {
7843 if (GetInt(113) != 0)
7844 {
7845 return;
7846 }
7847 _ListItems.Clear();
7848 Thing bestRangedWeapon = GetBestRangedWeapon();
7849 foreach (Thing thing in things)
7850 {
7851 if (!thing.IsAmmo && !thing.c_isImportant)
7852 {
7853 if (thing.category.slot != 0 && !thing.isEquipped && !thing.HasTag(CTAG.gift))
7854 {
7855 _ListItems.Add(thing);
7856 }
7857 else if (thing.IsRangedWeapon && thing.category.slot == 0 && bestRangedWeapon != thing)
7858 {
7859 _ListItems.Add(thing);
7860 }
7861 }
7862 }
7863 if (_ListItems.Count == 0)
7864 {
7865 return;
7866 }
7867 List<Thing> containers2 = containers.ToList();
7868 foreach (Thing listItem in _ListItems)
7869 {
7870 EClass._zone.TryAddThingInSharedContainer(listItem, containers2, add: true, msg: true, this);
7871 }
7872 }
7873
7874 public void TryPutSharedItems(bool msg = true)
7875 {
7876 TryPutSharedItems(EClass._map.props.installed.containers);
7877 }
7878
7879 public void TryTakeSharedItems(bool msg = true)
7880 {
7881 TryTakeSharedItems(EClass._map.props.installed.containers);
7882 }
7883
7884 public void TryTakeSharedItems(IEnumerable<Thing> containers, bool msg = true, bool shouldEat = true)
7885 {
7886 if (base.isSummon || (memberType == FactionMemberType.Livestock && homeBranch != null && !homeBranch.policies.IsActive(2715)))
7887 {
7888 return;
7889 }
7890 int num = 2;
7891 int num2 = 1;
7892 int num3 = 2;
7893 bool flag = GetInt(113) == 0;
7894 int num4 = 2;
7895 int num5 = 2;
7896 int num6 = 2;
7897 if (homeBranch != null && homeBranch.HasItemProtection && !IsPCParty)
7898 {
7899 num5 = 0;
7900 num6 = 0;
7901 }
7902 foreach (Thing thing3 in things)
7903 {
7904 if (CanEat(thing3, shouldEat))
7905 {
7906 if (thing3.HasElement(757))
7907 {
7908 num2 -= thing3.Num;
7909 num -= thing3.Num;
7910 }
7911 else
7912 {
7913 num -= thing3.Num;
7914 }
7915 }
7916 if (thing3.trait.GetHealAction(this) != null)
7917 {
7918 num3 -= thing3.Num;
7919 }
7920 if (thing3.id == "polish_powder")
7921 {
7922 num4 -= thing3.Num;
7923 }
7924 if (thing3.trait is TraitBlanketColdproof)
7925 {
7926 num5 -= thing3.Num;
7927 }
7928 if (thing3.trait is TraitBlanketFireproof)
7929 {
7930 num6 -= thing3.Num;
7931 }
7932 }
7933 _ListItems.Clear();
7934 foreach (Thing container in containers)
7935 {
7936 if (!container.IsSharedContainer)
7937 {
7938 continue;
7939 }
7940 foreach (Thing thing4 in container.things)
7941 {
7942 if (!thing4.c_isImportant && thing4.IsIdentified && thing4 != EClass.pc.held)
7943 {
7944 if (num4 > 0 && thing4.id == "polish_powder")
7945 {
7946 _ListItems.Add(thing4);
7947 num4 -= thing4.Num;
7948 }
7949 else if (num5 > 0 && !HasElement(1236) && thing4.trait is TraitBlanketColdproof)
7950 {
7951 _ListItems.Add(thing4);
7952 num5 -= thing4.Num;
7953 }
7954 else if (num6 > 0 && thing4.trait is TraitBlanketFireproof)
7955 {
7956 _ListItems.Add(thing4);
7957 num6 -= thing4.Num;
7958 }
7959 else if (num2 > 0 && CanEat(thing4, shouldEat) && !thing4.c_isImportant && thing4.HasElement(757))
7960 {
7961 _ListItems.Add(thing4);
7962 num2 -= thing4.Num;
7963 }
7964 else if (num > 0 && CanEat(thing4, shouldEat) && !thing4.c_isImportant)
7965 {
7966 _ListItems.Add(thing4);
7967 num -= thing4.Num;
7968 }
7969 else if (num3 > 0 && thing4.trait.GetHealAction(this) != null)
7970 {
7971 _ListItems.Add(thing4);
7972 num3 -= thing4.Num;
7973 }
7974 else if (flag && thing4.IsEquipmentOrRanged && !thing4.HasTag(CTAG.gift) && ShouldEquip(thing4, useFav: true))
7975 {
7976 _ListItems.Add(thing4);
7977 }
7978 }
7979 }
7980 }
7981 if (_ListItems.Count == 0)
7982 {
7983 return;
7984 }
7985 _ListItems.ForeachReverse(delegate(Thing t)
7986 {
7987 if (t.IsEquipmentOrRanged)
7988 {
7989 bool flag3 = false;
7990 int slot = t.category.slot;
7991 int equipValue = t.GetEquipValue();
7992 foreach (Thing listItem in _ListItems)
7993 {
7994 if (listItem.category.slot == slot && listItem.GetEquipValue() > equipValue)
7995 {
7996 flag3 = true;
7997 break;
7998 }
7999 }
8000 if (flag3)
8001 {
8002 _ListItems.Remove(t);
8003 }
8004 }
8005 });
8006 bool flag2 = false;
8007 foreach (Thing listItem2 in _ListItems)
8008 {
8009 Thing thing = listItem2;
8010 if (things.IsFull(thing))
8011 {
8012 break;
8013 }
8014 Thing thing2 = listItem2.parent as Thing;
8015 if (thing.HasElement(757))
8016 {
8017 if (thing.Num > 1)
8018 {
8019 thing = thing.Split(1);
8020 }
8021 }
8022 else if (thing.Num > 2)
8023 {
8024 thing = thing.Split(2);
8025 }
8026 if (msg)
8027 {
8028 Say("takeSharedItem", this, thing, thing2.GetName(NameStyle.Full));
8029 }
8030 AddCard(thing);
8031 if (ShouldEquip(thing, useFav: true) && thing.category.slot != 0)
8032 {
8033 TryEquip(thing, useFav: true);
8034 flag2 = true;
8035 }
8036 }
8037 if (flag2 && flag)
8038 {
8039 TryPutSharedItems(containers);
8040 }
8041 }
8042
8044 {
8045 Thing result = null;
8046 int num = -1;
8047 if (IsPC)
8048 {
8049 return null;
8050 }
8051 foreach (Thing item in things.List((Thing t) => CanEat(t, shouldEat: true) && !t.c_isImportant, onlyAccessible: true))
8052 {
8053 int num2 = CountNumEaten(item);
8054 int num3 = 100 - num2 + (item.HasElement(757) ? 10 : 0);
8055 if (num3 > num)
8056 {
8057 result = item;
8058 num = num3;
8059 }
8060 }
8061 return result;
8062 }
8063
8064 public void InstantEat(Thing t = null, bool sound = true)
8065 {
8066 if (t == null)
8067 {
8068 t = FindBestFoodToEat();
8069 }
8070 if (t == null)
8071 {
8072 t = things.Find((Thing a) => CanEat(a, shouldEat: true) && !a.c_isImportant);
8073 }
8074 if (t == null)
8075 {
8076 t = things.Find((Thing a) => CanEat(a) && !a.c_isImportant);
8077 }
8078 if (t != null)
8079 {
8080 Say("eat_start", this, t.Duplicate(1));
8081 if (sound)
8082 {
8083 PlaySound("eat");
8084 }
8085 FoodEffect.Proc(this, t);
8086 }
8087 }
8088
8089 public bool CanEat(Thing t, bool shouldEat = false)
8090 {
8091 if (t.IsDecayed && !HasElement(480))
8092 {
8093 return false;
8094 }
8095 if (HasElement(1250) && !t.HasElement(710))
8096 {
8097 return false;
8098 }
8099 if (shouldEat && (!(t.trait is TraitFoodPrepared) || t.c_isImportant))
8100 {
8101 return false;
8102 }
8103 if ((IsPC || (homeBranch != null && homeBranch.GetCivility() >= 50)) && (t.HasTag(CTAG.dish_fail) || t.id == "731"))
8104 {
8105 return false;
8106 }
8107 if (!t.IsNegativeGift && !t.HasTag(CTAG.ignoreUse) && !t.isEquipped)
8108 {
8109 return t.trait.CanEat(this);
8110 }
8111 return false;
8112 }
8113
8114 public bool ShouldEquip(Thing t, bool useFav = false)
8115 {
8116 if (t.IsRangedWeapon && t.category.slot == 0)
8117 {
8118 if (!CanEquipRanged(t))
8119 {
8120 return false;
8121 }
8122 int num = 0;
8123 foreach (Thing thing in things)
8124 {
8125 if (thing.IsRangedWeapon)
8126 {
8127 if (thing.category.slot != 0 && thing.isEquipped)
8128 {
8129 return false;
8130 }
8131 if (CanEquipRanged(thing) && thing.GetEquipValue() > num)
8132 {
8133 num = thing.GetEquipValue();
8134 }
8135 }
8136 }
8137 if (t.GetEquipValue() > num)
8138 {
8139 return true;
8140 }
8141 return false;
8142 }
8143 BodySlot bodySlot = body.GetSlot(t);
8144 if (bodySlot == null)
8145 {
8146 return false;
8147 }
8148 if (useFav)
8149 {
8150 switch (GetFavAttackStyle())
8151 {
8152 case AttackStyle.Default:
8153 case AttackStyle.TwoHand:
8154 if (t.IsMeleeWeapon)
8155 {
8156 bodySlot = body.slotMainHand;
8157 }
8158 else if (bodySlot.elementId == 35)
8159 {
8160 return false;
8161 }
8162 break;
8163 case AttackStyle.Shield:
8164 if (t.IsMeleeWeapon)
8165 {
8166 bodySlot = body.slotMainHand;
8167 }
8168 else if (bodySlot.elementId == 35 && t.IsMeleeWeapon)
8169 {
8170 return false;
8171 }
8172 break;
8173 case AttackStyle.TwoWield:
8174 if (bodySlot.elementId == 35 && !t.IsMeleeWeapon)
8175 {
8176 return false;
8177 }
8178 break;
8179 }
8180 }
8181 if (!body.IsEquippable(t, bodySlot, text: false))
8182 {
8183 return false;
8184 }
8185 if (bodySlot.thing != null && (bodySlot.thing.blessedState <= BlessedState.Cursed || bodySlot.thing.GetEquipValue() >= t.GetEquipValue()))
8186 {
8187 return false;
8188 }
8189 if (!base.IsPCFactionOrMinion)
8190 {
8191 int num2 = 0;
8192 foreach (Element value in t.elements.dict.Values)
8193 {
8194 if (value.Value <= 0)
8195 {
8196 int num3 = 100;
8197 switch (value.id)
8198 {
8199 case 418:
8200 num3 = 10;
8201 break;
8202 case 60:
8203 case 61:
8204 case 62:
8205 num3 = 200;
8206 break;
8207 case 962:
8208 num3 = 10000;
8209 break;
8210 }
8211 num2 += value.Value * num3 / 100;
8212 }
8213 }
8214 if (num2 < -40)
8215 {
8216 return false;
8217 }
8218 }
8219 if (t.HasTag(CTAG.gift) && t.c_uidAttune != base.uid)
8220 {
8221 return false;
8222 }
8223 return true;
8224 }
8225
8226 public bool TryEquip(Thing t, bool useFav = false)
8227 {
8228 if (!ShouldEquip(t, useFav))
8229 {
8230 return false;
8231 }
8232 if (t.category.slot == 0)
8233 {
8234 return false;
8235 }
8236 if (useFav)
8237 {
8238 BodySlot slot = body.GetSlot(t);
8239 switch (GetFavAttackStyle())
8240 {
8241 case AttackStyle.Default:
8242 case AttackStyle.TwoHand:
8243 if (t.IsMeleeWeapon)
8244 {
8245 slot = body.slotMainHand;
8246 }
8247 break;
8248 case AttackStyle.Shield:
8249 if (t.IsMeleeWeapon)
8250 {
8251 slot = body.slotMainHand;
8252 }
8253 break;
8254 }
8255 body.Equip(t, slot);
8256 }
8257 else
8258 {
8259 body.Equip(t);
8260 }
8261 Say("equip", this, t);
8262 return true;
8263 }
8264
8265 public bool CanEquipRanged(Thing t)
8266 {
8267 return !body.IsTooHeavyToEquip(t);
8268 }
8269
8271 {
8272 Thing dest = null;
8273 if (IsPC)
8274 {
8276 {
8277 return FindThrowable(hotbar: true);
8278 }
8279 return null;
8280 }
8281 things.Foreach(delegate(Thing t)
8282 {
8283 if (t.HasTag(CTAG.throwWeapon) || (!base.IsPCFactionOrMinion && t.HasTag(CTAG.throwWeaponEnemy)))
8284 {
8285 dest = t;
8286 }
8287 });
8288 return dest;
8289 Thing FindThrowable(bool hotbar)
8290 {
8291 things.Foreach(delegate(Thing t)
8292 {
8293 if (dest == null)
8294 {
8295 if (t.IsHotItem)
8296 {
8297 if (!hotbar)
8298 {
8299 return;
8300 }
8301 }
8302 else if (hotbar)
8303 {
8304 return;
8305 }
8306 if (t.HasTag(CTAG.throwWeapon))
8307 {
8308 dest = t;
8309 }
8310 }
8311 });
8312 return dest;
8313 }
8314 }
8315
8317 {
8318 TraitToolRange ranged = weapon.trait as TraitToolRange;
8319 Thing thing = (IsPC ? EClass.pc.things.Find<TraitQuiver>() : null);
8320 if (thing != null)
8321 {
8322 Thing thing2 = thing.things.Find((Thing t) => ranged.IsAmmo(t));
8323 if (thing2 != null)
8324 {
8325 return thing2;
8326 }
8327 }
8328 return things.Find((Thing t) => ranged.IsAmmo(t));
8329 }
8330
8332 {
8333 Thing result = null;
8334 int num = 0;
8335 foreach (Thing thing in things)
8336 {
8337 if (thing.IsRangedWeapon && CanEquipRanged(thing) && thing.GetEquipValue() > num)
8338 {
8339 num = thing.GetEquipValue();
8340 result = thing;
8341 }
8342 }
8343 return result;
8344 }
8345
8347 {
8348 return things.List((Thing t) => t.IsRangedWeapon && CanEquipRanged(t)).RandomItem();
8349 }
8350
8351 public bool TryEquipRanged()
8352 {
8353 if (id == "mamani")
8354 {
8355 ranged = GetRandomRangedWeapon();
8356 }
8357 if (IsPC)
8358 {
8360 if (thing?.trait is TraitToolRange && CanEquipRanged(thing))
8361 {
8362 ranged = thing;
8363 return true;
8364 }
8365 return false;
8366 }
8367 if (ranged != null && ranged.parent == this)
8368 {
8369 return true;
8370 }
8371 ranged = GetBestRangedWeapon();
8372 return ranged != null;
8373 }
8374
8375 public override int GetArmorSkill()
8376 {
8377 if (body.GetWeight(armorOnly: true) <= (HasElement(1204) ? 6000 : 30000))
8378 {
8379 return 120;
8380 }
8381 return 122;
8382 }
8383
8384 public bool TryUse(Thing t)
8385 {
8386 if (t.id == "338" && t.blessedState >= BlessedState.Normal)
8387 {
8388 Thing thing = things.Find((Thing a) => a.IsEquipmentOrRanged && !a.isAcidproof);
8389 if (thing != null)
8390 {
8391 Say("dip", this, thing, t.GetName(NameStyle.Full, 1));
8392 SE.Change();
8393 t.trait.OnBlend(thing, this);
8394 return true;
8395 }
8396 return false;
8397 }
8398 if (t.IsNegativeGift || t.source.HasTag(CTAG.ignoreUse))
8399 {
8400 return false;
8401 }
8402 if (t.id == "cigar")
8403 {
8404 (t.trait as TraitItemProc).OnUse(this);
8405 return true;
8406 }
8407 if (t.trait.CanDrink(this))
8408 {
8409 Drink(t);
8410 return true;
8411 }
8412 if (t.trait.CanEat(this) && hunger.GetPhase() > ((IsPCFaction || IsPCFactionMinion) ? 2 : 0))
8413 {
8414 SetAIImmediate(new AI_Eat
8415 {
8416 target = t
8417 });
8418 return true;
8419 }
8420 if (t.trait.CanRead(this))
8421 {
8422 SetAIImmediate(new AI_Read
8423 {
8424 target = t
8425 });
8426 return true;
8427 }
8428 if (base.hp < MaxHP * 90 / 100)
8429 {
8430 Action healAction = t.trait.GetHealAction(this);
8431 if (healAction != null)
8432 {
8433 healAction();
8434 return true;
8435 }
8436 }
8437 return false;
8438 }
8439
8441 {
8442 return FindBed()?.owner.pos.cell.room;
8443 }
8444
8445 public void ModAffinity(Chara c, int a, bool show = true, bool showOnlyEmo = false)
8446 {
8447 if (c == this)
8448 {
8449 return;
8450 }
8451 if (IsPC)
8452 {
8453 c.ModAffinity(EClass.pc, a, show);
8454 }
8455 else
8456 {
8457 if (!trait.CanChangeAffinity)
8458 {
8459 return;
8460 }
8461 int num = StatsHygiene.GetAffinityMod(EClass.pc.hygiene.GetPhase()) + (HasElement(417) ? 30 : 0) + (EClass.pc.HasCondition<ConSmoking>() ? (-30) : 0);
8462 if (IsPCFaction && homeBranch != null)
8463 {
8464 num += (int)Mathf.Sqrt(homeBranch.Evalue(2117)) * 5;
8465 }
8466 bool flag = a > 0;
8467 if (flag)
8468 {
8469 a = a * num / 100;
8470 if (affinity.GetLunchChance() > EClass.rnd(100) && GetInt(71) >= 0 && GetInt(71) < EClass.world.date.GetRaw())
8471 {
8472 SetInt(71, -1);
8473 }
8474 }
8475 if (show)
8476 {
8477 if (a == 0)
8478 {
8479 if (!showOnlyEmo)
8480 {
8481 Say("affinityNone", this, c);
8482 }
8483 }
8484 else
8485 {
8486 ShowEmo((!flag) ? Emo.angry : Emo.love);
8487 c.ShowEmo(flag ? Emo.love : Emo.sad);
8488 if (!showOnlyEmo)
8489 {
8490 Say(flag ? "affinityPlus" : "affinityMinus", this, c);
8491 }
8492 }
8493 }
8494 if (c.IsPC)
8495 {
8496 a = affinity.Mod(a);
8497 }
8498 }
8499 }
8500
8501 public bool TryIdentify(Thing t, int count = 1, bool show = true)
8502 {
8503 int num = Evalue(289);
8504 if (num == 0)
8505 {
8506 return false;
8507 }
8508 int lV = t.LV;
8509 if (EClass.rnd(num * num + 5) > EClass.rnd(lV * lV) * 20)
8510 {
8511 t.Identify(show, (num >= 20) ? IDTSource.SkillHigh : IDTSource.Skill);
8512 int num2 = 50;
8513 if (lV > num)
8514 {
8515 num2 += (lV - num) * 10;
8516 }
8517 elements.ModExp(289, Mathf.Min(num2, 1000));
8518 return true;
8519 }
8520 return false;
8521 }
8522
8524 {
8525 Chara chara = CharaGen.Create(id);
8526 chara.c_originalHostility = base.c_originalHostility;
8527 if (chara.c_originalHostility != 0)
8528 {
8529 chara.hostility = chara.c_originalHostility;
8530 }
8531 if (orgPos != null)
8532 {
8533 chara.orgPos = orgPos.Copy();
8534 }
8535 chara.pos = pos.Copy();
8536 chara.isImported = true;
8537 chara.c_editorTags = base.c_editorTags;
8538 chara.c_editorTraitVal = base.c_editorTraitVal;
8539 chara.c_idTrait = base.c_idTrait;
8540 chara.homeZone = homeZone;
8541 return chara;
8542 }
8543
8545 {
8546 if (ModUtil.TryGetContent<CustomBiographyContent>("Biography/" + id, out var content))
8547 {
8548 content.RefreshCharaBio(this);
8549 if (!content.favFood.IsEmpty() && EClass.sources.things.map.TryGetValue(content.favFood, out var value))
8550 {
8551 return value;
8552 }
8553 }
8554 string str = GetStr(72);
8555 if (!str.IsEmpty() && EClass.sources.things.map.TryGetValue(str, out var value2))
8556 {
8557 return value2;
8558 }
8559 if (_listFavFood.Count == 0)
8560 {
8561 foreach (SourceThing.Row row in EClass.sources.things.rows)
8562 {
8563 if (row._origin == "dish" && row.value != 0 && row.chance != 0)
8564 {
8565 _listFavFood.Add(row);
8566 }
8567 }
8568 }
8569 SourceThing.Row r = null;
8570 Rand.UseSeed(base.uid + EClass.game.seed, delegate
8571 {
8572 r = _listFavFood.RandomItem();
8573 });
8574 return r;
8575 }
8576
8578 {
8579 if (ModUtil.TryGetContent<CustomBiographyContent>("Biography/" + id, out var content))
8580 {
8581 content.RefreshCharaBio(this);
8582 if (!content.favCategory.IsEmpty() && EClass.sources.categories.map.TryGetValue(content.favCategory, out var value) && value.gift > 0)
8583 {
8584 return value;
8585 }
8586 }
8587 string str = GetStr(73);
8588 if (!str.IsEmpty() && EClass.sources.categories.map[str] != null)
8589 {
8590 return EClass.sources.categories.map[str];
8591 }
8592 SourceCategory.Row r = null;
8593 if (_listFavCat.Count == 0)
8594 {
8595 foreach (SourceCategory.Row row in EClass.sources.categories.rows)
8596 {
8597 if (row.gift > 0)
8598 {
8599 _listFavCat.Add(row);
8600 }
8601 }
8602 }
8603 Rand.UseSeed(base.uid + EClass.game.seed, delegate
8604 {
8605 r = _listFavCat.RandomItem();
8606 });
8607 return r;
8608 }
8609
8610 public void Marry(Chara c)
8611 {
8612 if (base.c_love == null)
8613 {
8614 base.c_love = new LoveData();
8615 }
8616 base.c_love.dateMarriage = EClass.world.date.GetRaw();
8617 base.c_love.uidZoneMarriage = EClass._zone.uid;
8618 base.c_love.nameZoneMarriage = EClass._zone.Name;
8619 SetFeat(1275, 1, msg: true);
8621 }
8622
8623 public void Divorce(Chara c)
8624 {
8625 if (base.c_love != null)
8626 {
8627 base.c_love.dateMarriage = 0;
8628 base.c_love.dateWedding = 0;
8629 SetFeat(1275, 0);
8631 }
8632 }
8633
8635 {
8636 using (List<Chara>.Enumerator enumerator = pos.ListCharasInRadius(this, 3, (Chara c) => c != this && c.race.id == "cat").GetEnumerator())
8637 {
8638 if (enumerator.MoveNext())
8639 {
8640 return enumerator.Current;
8641 }
8642 }
8643 return null;
8644 }
8645
8646 public void Sniff(Chara c)
8647 {
8648 Say("abCatSniff", this, c);
8649 AddCondition<ConHOT>(EClass.curve(50 + c.CHA * 5, 400, 100));
8650 c.ShowEmo(Emo.angry);
8651 ShowEmo(Emo.love);
8652 Talk("sniff");
8653 c.Talk(new string[4] { "labor", "disgust", "scold", "callGuards" }.RandomItem());
8654 }
8655
8656 public int GetTotalFeat()
8657 {
8658 int num = 0;
8659 if (base.c_upgrades != null)
8660 {
8661 num += base.c_upgrades.spent;
8662 }
8663 if (base.c_genes != null)
8664 {
8665 num += base.c_genes.GetTotalCost();
8666 }
8667 return num + base.feat;
8668 }
8669
8670 public bool CanInsult()
8671 {
8672 foreach (ActList.Item item in ability.list.items)
8673 {
8674 if (item.act.id == 6630)
8675 {
8676 return true;
8677 }
8678 }
8679 return false;
8680 }
8681
8682 public string GetIdPortraitCat()
8683 {
8684 string text = race.id;
8685 if ((text == "mifu" || text == "nefu") && EClass.rnd(2) == 0)
8686 {
8687 return "foxfolk";
8688 }
8689 if (trait is TraitGuard)
8690 {
8691 return "guard";
8692 }
8693 return "";
8694 }
8695
8696 public string GetIdPortrait()
8697 {
8698 string str = GetStr("portrait_override");
8699 if (!str.IsEmpty() && Portrait.allIds.Contains(str + ".png"))
8700 {
8701 return str;
8702 }
8703 if (id == "olderyoungersister")
8704 {
8705 if (base.idSkin != 2)
8706 {
8707 return "UN_olderyoungersister";
8708 }
8709 return "UN_olderyoungersister_alt";
8710 }
8711 if (Portrait.allIds.Contains("UN_" + id + ".png"))
8712 {
8713 return "UN_" + id;
8714 }
8715 return base.c_idPortrait;
8716 }
8717
8718 public Thing MakeGene(DNA.Type? type = null)
8719 {
8720 return DNA.GenerateGene(((HasElement(1290) || HasElement(1292)) && Evalue(418) >= 0) ? EClass.sources.charas.map["caladrius"].model.Chara : this, type);
8721 }
8722
8724 {
8725 return DNA.GenerateGene(this, DNA.Type.Brain);
8726 }
8727
8728 public void OnInsulted()
8729 {
8730 if (isDead)
8731 {
8732 return;
8733 }
8734 if (HasElement(1231))
8735 {
8736 Talk("insulted");
8737 AddCondition<ConEuphoric>(100 * Evalue(1231));
8738 }
8739 else if (EClass.rnd(20) == 0)
8740 {
8741 SetFeat(1231, 1, msg: true);
8742 if (IsPC)
8743 {
8745 }
8746 }
8747 }
8748
8749 public bool IsValidGiftWeight(Card t, int num = -1)
8750 {
8751 int num2 = ((!HasElement(1411)) ? 1 : 3);
8752 if (GetBurden(t, num) >= num2)
8753 {
8754 return false;
8755 }
8756 return true;
8757 }
8758
8759 public bool CanAcceptItem(Card t, int num = -1, bool skipImportantCheck = false)
8760 {
8762 {
8763 return true;
8764 }
8765 if (!IsValidGiftWeight(t, num))
8766 {
8767 return false;
8768 }
8769 if (!skipImportantCheck && t.c_isImportant)
8770 {
8771 return false;
8772 }
8773 if ((t.category.IsChildOf("furniture") || t.category.IsChildOf("junk")) && (!(t.trait is TraitFigure) || !HasElement(1427)) && !HasElement(1411))
8774 {
8775 return false;
8776 }
8777 return true;
8778 }
8779
8780 public bool CanAcceptGift(Chara c, Card t)
8781 {
8782 if (things.IsFull())
8783 {
8784 return false;
8785 }
8786 if (t.c_isImportant)
8787 {
8788 return false;
8789 }
8790 if (t.id == "1084")
8791 {
8792 return true;
8793 }
8794 if (t.trait is TraitBookExp)
8795 {
8796 return true;
8797 }
8798 if (t.trait.CanOnlyCarry || !t.trait.CanBeDestroyed || t.trait.CanExtendBuild || t.rarity == Rarity.Artifact || t.IsContainer)
8799 {
8800 return false;
8801 }
8802 if (base.IsPowerful && t.trait is TraitScroll { source: not null } traitScroll && traitScroll.source.abilityType.Contains("summon"))
8803 {
8804 return false;
8805 }
8806 return true;
8807 }
8808
8809 public void GiveGift(Chara c, Thing t)
8810 {
8811 if (c.IsHostile() || c.IsDeadOrSleeping)
8812 {
8813 Msg.Say("affinityNone", c, this);
8814 return;
8815 }
8816 if (!t.isCopy && t.IsCursed && t.IsEquipmentOrRanged && !t.IsAmmo && c.HasElement(1414))
8817 {
8818 bool num = t.blessedState == BlessedState.Doomed;
8819 int num2 = 200 + t.LV * 3;
8820 if (t.rarity == Rarity.Legendary)
8821 {
8822 num2 *= 3;
8823 }
8824 if (t.rarity >= Rarity.Mythical)
8825 {
8826 num2 *= 5;
8827 }
8828 if (num)
8829 {
8830 num2 *= 2;
8831 }
8832 PlayEffect("identify");
8833 PlaySound("identify");
8834 c.PlayEffect("mutation");
8835 c.Say("draw_curse", c, t);
8836 t.Destroy();
8837 List<Element> list = new List<Element>();
8838 foreach (Element value in elements.dict.Values)
8839 {
8840 if (value is Spell)
8841 {
8842 list.Add(value);
8843 }
8844 }
8845 if (list.Count == 0)
8846 {
8847 SayNothingHappans();
8848 return;
8849 }
8850 Element element = list.RandomItem();
8851 ModExp(element.id, num2);
8852 Say("draw_curse2", this, element.Name);
8853 c.AddExp(Mathf.Min(num2 / 3, c.ExpToNext));
8854 return;
8855 }
8856 if ((t.id == "lovepotion" || t.id == "dreambug") && !Application.isEditor)
8857 {
8858 GiveLovePotion(c, t);
8859 return;
8860 }
8861 if (t.trait is TraitErohon && c.id == t.c_idRefName)
8862 {
8863 c.OnGiveErohon(t);
8864 return;
8865 }
8866 if (t.trait is TraitTicketMassage)
8867 {
8868 t.ModNum(-1);
8869 c.Talk("ticket");
8870 switch (t.id)
8871 {
8872 case "ticket_massage":
8873 c.ModAffinity(EClass.pc, 10);
8875 {
8876 target = c
8877 });
8878 break;
8879 case "ticket_armpillow":
8880 c.ModAffinity(EClass.pc, 20);
8881 EClass.pc.AddCondition<ConSleep>(300, force: true);
8882 c.SetAI(new AI_ArmPillow
8883 {
8884 target = EClass.pc
8885 });
8886 break;
8887 case "ticket_champagne":
8888 c.ModAffinity(EClass.pc, 10);
8890 break;
8891 }
8892 return;
8893 }
8894 if (t.id == "flyer")
8895 {
8896 stamina.Mod(-1);
8897 if (c.things.Find((Thing a) => a.id == "flyer") != null)
8898 {
8899 c.Talk("flyer_miss");
8900 DoHostileAction(c);
8901 return;
8902 }
8903 if (EClass.rnd(20) != 0 && c.CHA > EClass.rnd(base.CHA + Evalue(291) * 3 + 10))
8904 {
8905 Msg.Say("affinityNone", c, this);
8906 t.Destroy();
8907 elements.ModExp(291, 10f);
8908 return;
8909 }
8910 elements.ModExp(291, 50f);
8911 }
8912 if (t.id == "statue_weird")
8913 {
8914 EClass.pc.Say("statue_sell");
8915 }
8916 t.isGifted = true;
8917 c.nextUse = c.affinity.OnGift(t);
8918 if (!t.isDestroyed)
8919 {
8920 EClass.game.quests.list.ForeachReverse(delegate(Quest q)
8921 {
8922 q.OnGiveItem(c, t);
8923 });
8924 if (c.TryEquip(t))
8925 {
8926 c.nextUse = null;
8927 }
8928 }
8929 if (c.IsPCParty)
8930 {
8932 }
8933 }
8934
8935 public void OnGiveErohon(Thing t)
8936 {
8937 Say("give_erohon", this);
8938 AddCondition<ConParalyze>(50, force: true);
8939 AddCondition<ConConfuse>(50, force: true);
8940 AddCondition<ConFear>(1000, force: true);
8941 ModAffinity(EClass.pc, 100);
8942 t.Destroy();
8943 Talk("pervert");
8944 }
8945
8946 public void GiveLovePotion(Chara c, Thing t)
8947 {
8948 c.Say("give_love", c, t);
8949 c.PlaySound(t.material.GetSoundDead());
8950 c.ShowEmo(Emo.angry);
8951 c.ModAffinity(EClass.pc, -20, show: false);
8952 c.Talk("pervert");
8953 t.Destroy();
8954 }
8955
8956 public bool RequestProtection(Chara attacker, Action<Chara> action)
8957 {
8958 if (HasCondition<StanceTaunt>() || base.isRestrained || attacker == this)
8959 {
8960 return false;
8961 }
8962 if (host != null && host.isRestrained)
8963 {
8964 return false;
8965 }
8966 if (base.IsPCFactionOrMinion && attacker.IsPCFactionOrMinion)
8967 {
8968 return false;
8969 }
8970 bool flag = false;
8971 foreach (Chara chara in EClass._map.charas)
8972 {
8973 if (chara == attacker || chara.enemy == this || chara == this || chara.host != null || chara.IsDisabled || !chara.IsFriendOrAbove(this) || chara.conSuspend != null || (chara.IsPCParty && !IsPCParty) || (IsPCFaction && !chara.IsPCFaction) || (attacker.IsPCFactionOrMinion && chara.IsPCFactionOrMinion) || chara.HasElement(1277))
8974 {
8975 continue;
8976 }
8977 bool flag2 = chara.HasElement(1225) && !chara.GetBool(126);
8978 if ((!flag2 && (flag || EClass.rnd(2) == 0 || !chara.HasCondition<StanceTaunt>())) || chara.HasCooldown(1225))
8979 {
8980 continue;
8981 }
8982 int num = Mathf.Max(chara.Evalue(1649), (!flag2) ? 1 : 3);
8983 int num2 = Dist(chara);
8984 if (num2 > 25)
8985 {
8986 continue;
8987 }
8988 if (num2 > num || !chara.CanSeeLos(pos, num2))
8989 {
8990 if (!flag2)
8991 {
8992 continue;
8993 }
8994 Point nearestPoint = pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true);
8995 if (!nearestPoint.IsValid)
8996 {
8997 continue;
8998 }
8999 chara.Teleport(nearestPoint);
9000 chara.AddCooldown(1225, 10);
9001 num2 = Dist(chara);
9002 Say("intercept_loyal", chara, this);
9003 chara.SetEnemy(attacker);
9004 attacker.SetEnemy(chara);
9005 if (num2 > num || !chara.CanSeeLos(pos, num2))
9006 {
9007 continue;
9008 }
9009 }
9010 if (!flag && !HasElement(1225))
9011 {
9012 Say("intercept", chara, this);
9013 if (EClass.rnd(10) == 0)
9014 {
9015 chara.Talk("intercept", base.NameSimple);
9016 }
9017 if (attacker.enemy == this)
9018 {
9019 attacker.SetEnemy(chara);
9020 }
9021 action(chara);
9022 flag = true;
9023 }
9024 }
9025 return flag;
9026 }
9027
9029 {
9030 if (IsPCFaction)
9031 {
9032 if (t.IsFood && t.category.id != "fish" && !t.IsDecayed)
9033 {
9034 return false;
9035 }
9036 if (t.trait.GetHealAction(this) != null)
9037 {
9038 return false;
9039 }
9040 if (t.IsThrownWeapon || t.IsRangedWeapon || t.IsAmmo)
9041 {
9042 return false;
9043 }
9044 if (t.trait is TraitBlanket || t.trait is TraitItemProc || t.trait is TraitBookSkill)
9045 {
9046 return false;
9047 }
9048 }
9049 if (t.isEquipped || t.rarity >= Rarity.Legendary || !t.trait.CanBeDestroyed || t.c_isImportant)
9050 {
9051 return false;
9052 }
9053 if (t.trait is TraitCurrency || t.trait is TraitTool)
9054 {
9055 return false;
9056 }
9057 switch (type)
9058 {
9059 case ClearInventoryType.SellAtTown:
9060 if (!t.isGifted && !t.isNPCProperty)
9061 {
9062 return false;
9063 }
9064 break;
9065 case ClearInventoryType.Purge:
9066 switch (t.category.id)
9067 {
9068 case "fish":
9069 if (EClass.rnd(3) == 0)
9070 {
9071 return true;
9072 }
9073 break;
9074 case "junk":
9075 case "garbage":
9076 if (EClass.rnd(3) != 0)
9077 {
9078 return true;
9079 }
9080 break;
9081 }
9082 if (t.id == "flyer")
9083 {
9084 return true;
9085 }
9086 if (!t.IsDecayed && EClass.rnd(3) == 0)
9087 {
9088 return false;
9089 }
9090 if (!things.IsFull() && t.IsRangedWeapon)
9091 {
9092 return false;
9093 }
9094 break;
9095 }
9096 return true;
9097 }
9098
9099 public void TryClearInventory()
9100 {
9101 if (IsPC)
9102 {
9103 return;
9104 }
9105 if (IsPCParty)
9106 {
9107 if (!things.IsAlmostFull())
9108 {
9109 return;
9110 }
9111 bool flag = EClass._zone.IsTown;
9112 if (!flag && EClass._zone.IsPCFactionOrTent)
9113 {
9114 foreach (Chara chara in EClass._map.charas)
9115 {
9116 if (chara.IsPCFaction && chara.trait.ShopType != ShopType.None)
9117 {
9118 flag = true;
9119 }
9120 }
9121 }
9122 if (flag)
9123 {
9124 ClearInventory(ClearInventoryType.SellAtTown);
9125 }
9126 }
9127 else
9128 {
9129 ClearInventory(ClearInventoryType.Purge);
9130 }
9131 }
9132
9134 {
9135 int num = 0;
9136 for (int num2 = things.Count - 1; num2 >= 0; num2--)
9137 {
9138 Thing thing = things[num2];
9139 if (ShouldThrowAway(thing, type))
9140 {
9141 num += thing.GetPrice(CurrencyType.Money, sell: true, PriceType.Default, this) * thing.Num;
9142 thing.Destroy();
9143 }
9144 }
9145 if (num > 0)
9146 {
9147 ModCurrency(num);
9148 if (type == ClearInventoryType.SellAtTown)
9149 {
9150 Msg.Say("party_sell", this, num.ToString() ?? "");
9151 PlaySound("pay");
9152 }
9153 }
9154 }
9155
9156 public void ResetUpgrade()
9157 {
9158 _ = base.c_upgrades;
9159 }
9160
9161 public void TryUpgrade(bool msg = true)
9162 {
9163 if (!EClass.debug.enable || IsPC || !IsGlobal || !IsPCFaction)
9164 {
9165 return;
9166 }
9167 for (int i = 0; i < 100; i++)
9168 {
9169 if (base.feat == 0)
9170 {
9171 break;
9172 }
9173 if (base.c_upgrades == null)
9174 {
9175 base.c_upgrades = new CharaUpgrade();
9176 }
9177 if (base.c_upgrades.halt)
9178 {
9179 break;
9180 }
9181 Rand.SetSeed(base.uid + base.c_upgrades.count);
9182 int num = EClass.rnd(100);
9183 int num2 = 0;
9184 int num3 = 1;
9185 int num4 = 0;
9186 bool flag = false;
9187 IEnumerable<SourceElement.Row> ie = EClass.sources.elements.rows.Where((SourceElement.Row a) => !elements.Has(a) && a.category == "skill" && !a.tag.Contains("noPet"));
9188 List<Element> list = ListAvailabeFeats(pet: true);
9189 if (num >= 90 && list.Count > 0)
9190 {
9191 Element element = list.RandomItem();
9192 num2 = element.id;
9193 num4 = element.CostLearn;
9194 }
9195 else if (num >= 60 && ie.Any())
9196 {
9197 num2 = ie.RandomItem().id;
9198 num4 = 3;
9199 }
9200 else
9201 {
9202 num2 = Element.List_MainAttributesMajor.RandomItem();
9203 num4 = 1;
9204 num3 = 2;
9205 flag = true;
9206 }
9207 Rand.SetSeed();
9208 if (num4 > base.feat)
9209 {
9210 break;
9211 }
9212 base.feat -= num4;
9213 base.c_upgrades.count++;
9214 base.c_upgrades.spent += num4;
9215 bool flag2 = false;
9216 if (flag)
9217 {
9218 foreach (CharaUpgrade.Item item in base.c_upgrades.items)
9219 {
9220 if (item.idEle == num2)
9221 {
9222 item.value += num3;
9223 item.cost += num4;
9224 flag2 = true;
9225 break;
9226 }
9227 }
9228 }
9229 if (!flag2)
9230 {
9231 base.c_upgrades.items.Add(new CharaUpgrade.Item
9232 {
9233 idEle = num2,
9234 value = num3,
9235 cost = num4
9236 });
9237 }
9238 SourceElement.Row row = EClass.sources.elements.map[num2];
9239 if (row.category == "feat")
9240 {
9241 SetFeat(num2, elements.ValueWithoutLink(num2) + 1, msg: true);
9242 }
9243 else if (elements.ValueWithoutLink(row.id) == 0)
9244 {
9245 elements.Learn(row.id);
9246 }
9247 else
9248 {
9249 elements.ModBase(num2, num3);
9250 }
9251 }
9252 }
9253
9254 public bool CanBloom()
9255 {
9256 if (IsPC || base.isScaled || HasElement(1273))
9257 {
9258 return false;
9259 }
9260 if (!EClass.debug.godMode)
9261 {
9262 if (base.c_daysWithPC > 360)
9263 {
9264 return affinity.CanSleepBeside();
9265 }
9266 return false;
9267 }
9268 return true;
9269 }
9270
9271 public void AddCooldown(int idEle, int turns = 0)
9272 {
9273 if (_cooldowns == null)
9274 {
9275 _cooldowns = new List<int>();
9276 }
9277 if (turns != 0)
9278 {
9279 _cooldowns.Add(idEle * 1000 + turns);
9280 return;
9281 }
9282 SourceElement.Row row = EClass.sources.elements.map[idEle];
9283 if (row.cooldown > 0)
9284 {
9285 _cooldowns.Add(idEle * 1000 + row.cooldown);
9286 }
9287 }
9288
9289 public void SetCooldown(int idEle, int turns = 0)
9290 {
9291 if (_cooldowns == null)
9292 {
9293 _cooldowns = new List<int>();
9294 }
9295 bool flag = false;
9296 for (int i = 0; i < _cooldowns.Count; i++)
9297 {
9298 if (_cooldowns[i] / 1000 == idEle)
9299 {
9300 if (turns == 0)
9301 {
9302 _cooldowns.RemoveAt(i);
9303 }
9304 else
9305 {
9306 _cooldowns[i] = idEle * 1000 + turns;
9307 }
9308 flag = true;
9309 break;
9310 }
9311 }
9312 if (!flag && turns > 0)
9313 {
9314 AddCooldown(idEle, turns);
9315 }
9316 if (_cooldowns.Count == 0)
9317 {
9318 _cooldowns = null;
9319 }
9320 }
9321
9322 public bool HasCooldown(int idEle)
9323 {
9324 return GetCooldown(idEle) != 0;
9325 }
9326
9327 public int GetCooldown(int idEle)
9328 {
9329 if (_cooldowns != null)
9330 {
9331 for (int i = 0; i < _cooldowns.Count; i++)
9332 {
9333 if (_cooldowns[i] / 1000 == idEle)
9334 {
9335 return _cooldowns[i] % 1000;
9336 }
9337 }
9338 }
9339 return 0;
9340 }
9341
9342 public void TickCooldown()
9343 {
9344 for (int num = _cooldowns.Count - 1; num >= 0; num--)
9345 {
9346 if (_cooldowns[num] % 1000 == 1)
9347 {
9348 _cooldowns.RemoveAt(num);
9349 }
9350 else
9351 {
9352 _cooldowns[num]--;
9353 }
9354 }
9355 if (_cooldowns.Count == 0)
9356 {
9357 _cooldowns = null;
9358 }
9359 }
9360
9361 public void ChooseNewGoal()
9362 {
9363 if (IsPC && EClass.AdvMode)
9364 {
9365 SetNoGoal();
9366 return;
9367 }
9368 if (IsPCParty || base.noMove)
9369 {
9370 SetAI(new GoalIdle());
9371 return;
9372 }
9373 if ((IsHomeMember() && IsInHomeZone()) || IsGuest())
9374 {
9375 Goal goalFromTimeTable = GetGoalFromTimeTable(EClass.world.date.hour);
9376 if (goalFromTimeTable != null)
9377 {
9378 SetAI(goalFromTimeTable);
9379 if (goalFromTimeTable is GoalWork)
9380 {
9381 goalFromTimeTable.Tick();
9382 }
9383 return;
9384 }
9385 }
9386 if (goalList.index == -2)
9387 {
9388 goalList.Refresh(this, goalListType);
9389 }
9390 SetAI(goalList.Next());
9391 }
9392
9394 {
9395 if (IsPC)
9396 {
9397 return null;
9398 }
9399 switch (TimeTable.GetSpan(idTimeTable, hour))
9400 {
9401 case TimeTable.Span.Sleep:
9402 if (sleepiness.value > 10 || EClass._zone.isSimulating)
9403 {
9404 return new GoalSleep();
9405 }
9406 break;
9407 case TimeTable.Span.Eat:
9408 return new GoalIdle();
9409 case TimeTable.Span.Work:
9410 if (IsGuest())
9411 {
9412 return new GoalIdle();
9413 }
9414 return GetGoalWork();
9415 case TimeTable.Span.Free:
9416 if (IsGuest())
9417 {
9418 return new GoalIdle();
9419 }
9420 return GetGoalHobby();
9421 }
9422 return null;
9423 }
9424
9426 {
9427 if (IsPrisoner)
9428 {
9429 return new GoalIdle();
9430 }
9431 if (memberType == FactionMemberType.Livestock)
9432 {
9433 return new GoalGraze();
9434 }
9435 return new GoalWork();
9436 }
9437
9439 {
9440 if (IsPrisoner)
9441 {
9442 return new GoalIdle();
9443 }
9444 if (memberType == FactionMemberType.Livestock)
9445 {
9446 return new GoalGraze();
9447 }
9448 return new GoalHobby();
9449 }
9450
9451 public bool HasHobbyOrWork(string alias)
9452 {
9453 int num = EClass.sources.hobbies.alias.TryGetValue(alias)?.id ?? 0;
9454 listHobby.Clear();
9455 if (_works == null || _hobbies == null)
9456 {
9457 RerollHobby();
9458 }
9459 foreach (int work in _works)
9460 {
9461 if (work == num)
9462 {
9463 return true;
9464 }
9465 }
9466 foreach (int hobby in _hobbies)
9467 {
9468 if (hobby == num)
9469 {
9470 return true;
9471 }
9472 }
9473 return false;
9474 }
9475
9476 public void SetAIIdle()
9477 {
9478 }
9479
9480 public void SetAIAggro()
9481 {
9482 SetAI(new GoalCombat());
9483 }
9484
9486 {
9487 return SetAI(_NoGoalPC);
9488 }
9489
9491 {
9492 if (IsPC)
9493 {
9495 }
9496 if (ai.IsRunning)
9497 {
9498 if (ai == g && ai.IsNoGoal)
9499 {
9500 return g;
9501 }
9502 ai.Cancel();
9503 if (ai == g)
9504 {
9505 Debug.Log("goal is g:" + ai?.ToString() + "/" + this);
9506 return g;
9507 }
9508 }
9509 if (HasCondition<ConWait>())
9510 {
9511 RemoveCondition<ConWait>();
9512 }
9513 ai = g;
9514 ai.SetOwner(this);
9515 if (IsPC)
9516 {
9517 renderer.RefreshStateIcon();
9518 }
9519 return g;
9520 }
9521
9522 public void SetAIImmediate(AIAct g)
9523 {
9524 bool hasNoGoal = HasNoGoal;
9525 SetAI(g);
9526 if ((EClass.scene.actionMode != ActionMode.Sim || !EClass.scene.paused) && hasNoGoal && !(renderer as CharaRenderer).IsMoving)
9527 {
9528 Tick();
9529 }
9530 }
9531
9533 {
9534 BaseArea result = null;
9535 foreach (Hobby item in ListWorks())
9536 {
9537 AIWork aI = item.GetAI(this);
9538 if (aI.SetDestination())
9539 {
9540 if (aI.destArea != null)
9541 {
9542 result = aI.destArea;
9543 }
9544 else if (aI.destThing != null)
9545 {
9546 result = aI.destThing.pos.cell.room;
9547 }
9548 break;
9549 }
9550 }
9551 return result;
9552 }
9553
9554 public List<Hobby> ListWorks(bool useMemberType = true)
9555 {
9556 listHobby.Clear();
9557 if (useMemberType && memberType == FactionMemberType.Livestock)
9558 {
9559 listHobby.Add(new Hobby
9560 {
9561 id = 45
9562 });
9563 }
9564 else
9565 {
9566 if (_works == null)
9567 {
9568 RerollHobby();
9569 }
9570 foreach (int work in _works)
9571 {
9572 listHobby.Add(new Hobby
9573 {
9574 id = work
9575 });
9576 }
9577 }
9578 return listHobby;
9579 }
9580
9581 public List<Hobby> ListHobbies(bool useMemberType = true)
9582 {
9583 listHobby.Clear();
9584 if (!useMemberType || memberType != FactionMemberType.Livestock)
9585 {
9586 if (_hobbies == null)
9587 {
9588 RerollHobby();
9589 }
9590 foreach (int hobby in _hobbies)
9591 {
9592 listHobby.Add(new Hobby
9593 {
9594 id = hobby
9595 });
9596 }
9597 }
9598 return listHobby;
9599 }
9600
9601 public Hobby GetWork(string id)
9602 {
9603 foreach (Hobby item in ListWorks())
9604 {
9605 if (item.source.alias == id)
9606 {
9607 return item;
9608 }
9609 }
9610 foreach (Hobby item2 in ListHobbies())
9611 {
9612 if (item2.source.alias == id)
9613 {
9614 return item2;
9615 }
9616 }
9617 return null;
9618 }
9619
9620 public void RefreshWorkElements(ElementContainer parent = null)
9621 {
9622 if (workElements != null)
9623 {
9624 workElements.SetParent();
9625 }
9626 workElements = null;
9627 if (IsPCParty || homeBranch == null || homeBranch.owner == null)
9628 {
9629 return;
9630 }
9631 foreach (Hobby item in ListHobbies())
9632 {
9633 TryAdd(item);
9634 }
9635 foreach (Hobby item2 in ListWorks())
9636 {
9637 TryAdd(item2);
9638 }
9639 if (workElements != null)
9640 {
9641 workElements.SetParent(parent);
9642 }
9643 void TryAdd(Hobby h)
9644 {
9645 if (!h.source.elements.IsEmpty())
9646 {
9647 if (workElements == null)
9648 {
9649 workElements = new ElementContainer();
9650 }
9651 for (int i = 0; i < h.source.elements.Length; i += 2)
9652 {
9653 int num = h.source.elements[i];
9654 int num2 = h.source.elements[i + 1];
9655 int num3 = 100;
9656 if (num != 2115 && num != 2207)
9657 {
9658 num3 = h.GetEfficiency(this) * homeBranch.efficiency / 100;
9659 if (num3 <= 0)
9660 {
9661 continue;
9662 }
9663 }
9664 workElements.ModBase(num, (num2 < 0) ? (num2 / 10) : Mathf.Max(1, h.source.elements[i + 1] * num3 / 1000));
9665 }
9666 }
9667 }
9668 }
9669
9670 public string GetTextHobby(bool simple = false)
9671 {
9672 string text = (simple ? "" : ("hobby".lang() + ":"));
9673 foreach (Hobby item in ListHobbies())
9674 {
9675 text = text + " " + item.Name.TagColor((item.GetEfficiency(this) > 0) ? FontColor.Good : FontColor.Warning) + ",";
9676 }
9677 return text.TrimEnd(',');
9678 }
9679
9680 public string GetTextWork(bool simple = false)
9681 {
9682 string text = (simple ? "" : ("work".lang() + ":"));
9683 foreach (Hobby item in ListWorks())
9684 {
9685 text = text + " " + item.Name.TagColor((item.GetEfficiency(this) > 0) ? FontColor.Good : FontColor.Warning) + ",";
9686 }
9687 return text.TrimEnd(',');
9688 }
9689
9690 public void AddHobby(int id)
9691 {
9692 foreach (int hobby in _hobbies)
9693 {
9694 if (hobby == id)
9695 {
9696 return;
9697 }
9698 }
9699 _hobbies.Add(id);
9700 }
9701
9702 public void AddWork(int id)
9703 {
9704 foreach (int work in _works)
9705 {
9706 if (work == id)
9707 {
9708 return;
9709 }
9710 }
9711 _works.Add(id);
9712 }
9713
9714 public void RerollHobby(bool extraSlotChance = true)
9715 {
9716 if (_hobbies != null && _works != null)
9717 {
9718 _hobbies.Clear();
9719 _works.Clear();
9720 }
9721 else
9722 {
9723 _hobbies = new List<int>();
9724 _works = new List<int>();
9725 }
9726 if (source.hobbies.IsEmpty())
9727 {
9728 AddHobby(EClass.sources.hobbies.listHobbies.RandomItem().id);
9729 }
9730 else
9731 {
9732 string[] hobbies = source.hobbies;
9733 foreach (string text in hobbies)
9734 {
9735 if (EClass.sources.hobbies.alias.TryGetValue(text.Trim(), out var value))
9736 {
9737 AddHobby(value.id);
9738 continue;
9739 }
9740 ModUtil.LogModError("source chara row '" + source.id + "' has invalid hobby '" + text + "'", source);
9741 }
9742 }
9743 if (source.works.IsEmpty())
9744 {
9745 AddWork(EClass.sources.hobbies.listWorks.RandomItem().id);
9746 }
9747 else
9748 {
9749 string[] hobbies = source.works;
9750 foreach (string text2 in hobbies)
9751 {
9752 if (EClass.sources.hobbies.alias.TryGetValue(text2.Trim(), out var value2))
9753 {
9754 AddWork(value2.id);
9755 continue;
9756 }
9757 ModUtil.LogModError("source chara row '" + source.id + "' has invalid work '" + text2 + "'", source);
9758 }
9759 }
9760 GetWorkSummary().Reset();
9761 }
9762
9764 {
9765 if (_workSummary == null)
9766 {
9767 _workSummary = new WorkSummary();
9768 }
9769 return _workSummary;
9770 }
9771
9772 public void TickWork(VirtualDate date)
9773 {
9774 TimeTable.Span span = TimeTable.GetSpan(idTimeTable, date.hour);
9775 if (span != TimeTable.Span.Work && span != TimeTable.Span.Free)
9776 {
9777 return;
9778 }
9779 WorkSummary workSummary = GetWorkSummary();
9780 if (span == TimeTable.Span.Work)
9781 {
9782 if (workSummary.work != null)
9783 {
9784 PerformWork(workSummary.work, isHobby: false, date.IsRealTime);
9785 }
9786 }
9787 else if (workSummary.hobbies.Count > 0)
9788 {
9789 PerformWork(workSummary.hobbies.RandomItem(), isHobby: true, date.IsRealTime);
9790 }
9791 }
9792
9793 public bool TryWorkOutside(SourceHobby.Row sourceWork)
9794 {
9795 if (EClass.world.date.IsExpired(GetInt(51)))
9796 {
9797 Expedition expedition = Expedition.Create(this, sourceWork.expedition.ToEnum<ExpeditionType>());
9798 SetInt(51, EClass.world.date.GetRaw() + 60 * (expedition.hours + 24));
9799 homeBranch.expeditions.Add(expedition);
9800 return true;
9801 }
9802 return false;
9803 }
9804
9805 public void PerformWork(WorkSession session, bool isHobby = false, bool IsRealTime = false)
9806 {
9807 Hobby hobby = new Hobby();
9808 hobby.id = session.id;
9809 WorkSummary workSummary = _workSummary;
9810 hobby.GetAI(this).OnPerformWork(IsRealTime);
9811 if (!isHobby)
9812 {
9813 workSummary.progress += EClass.rnd(5) + 5;
9814 }
9815 int num = PerformWork(hobby, 0, isHobby);
9816 int num2 = PerformWork(hobby, 1, isHobby);
9817 int num3 = PerformWork(hobby, 2, isHobby);
9818 int num4 = PerformWork(hobby, 3, isHobby);
9819 workSummary.money += num;
9820 workSummary.food += num2;
9821 workSummary.knowledge += num3;
9822 workSummary.material += num4;
9823 int PerformWork(Hobby work, int idx, bool flag)
9824 {
9825 if (idx >= work.source.resources.Length)
9826 {
9827 return 0;
9828 }
9829 int num5 = work.source.resources[idx];
9830 int num6 = num5;
9831 num5 = Rand.Range(num5 * (100 - work.source.resources[idx]) / 100, num5);
9832 num5 = num5 * (flag ? 50 : 100) * session.efficiency / 10000;
9833 if (num6 > 0 && num5 <= 0)
9834 {
9835 num5 = 1;
9836 }
9837 return num5;
9838 }
9839 }
9840
9841 public void ValidateWorks()
9842 {
9843 _goalWork.FindWork(this, setAI: false);
9844 _goalHobby.ValidateHobby(this);
9845 }
9846
9847 public void InitStats(bool onDeserialize = false)
9848 {
9849 if (!onDeserialize)
9850 {
9851 _cints[10] = 20;
9852 _cints[11] = 70;
9853 _cints[13] = 70;
9854 _cints[14] = 70;
9855 _cints[15] = 70;
9856 _cints[17] = 0;
9857 _cints[18] = 0;
9858 }
9859 foreach (Condition condition in conditions)
9860 {
9861 condition.SetOwner(this, onDeserialize);
9862 }
9863 }
9864
9865 public Condition AddCondition<T>(int p = 100, bool force = false) where T : Condition
9866 {
9867 return AddCondition(typeof(T).Name, p, force);
9868 }
9869
9870 public Condition AddCondition<T>(int p, int p2, bool force = false) where T : Condition
9871 {
9872 return AddCondition(typeof(T).Name, p, p2, force);
9873 }
9874
9875 public Condition AddCondition(string id, int p = 100, bool force = false)
9876 {
9877 return AddCondition(Condition.Create(id, p), force);
9878 }
9879
9880 public Condition AddCondition(string id, int p, int p2, bool force = false)
9881 {
9882 Condition condition = Condition.Create(id, p);
9883 condition.P2 = p2;
9884 return AddCondition(condition, force);
9885 }
9886
9887 public Condition AddCondition(Condition c, bool force = false)
9888 {
9889 c.owner = this;
9890 if (!(c is ConBurning))
9891 {
9892 if (c is ConBleed && ResistLv(964) >= 3)
9893 {
9894 return null;
9895 }
9896 }
9897 else if (ResistLv(950) >= 3)
9898 {
9899 return null;
9900 }
9901 if (c.GainResistFactor > 0 && CanGainConResist)
9902 {
9903 if (c.GainResistFactor >= 400)
9904 {
9905 c.power /= 2;
9906 }
9907 ResistCon(c);
9908 if (c.power <= 0)
9909 {
9910 return null;
9911 }
9912 }
9913 if (!force)
9914 {
9915 if (c.source.negate.Length != 0)
9916 {
9917 string[] negate = c.source.negate;
9918 foreach (string text in negate)
9919 {
9920 if (HasElement(text))
9921 {
9922 return null;
9923 }
9924 }
9925 }
9926 Element defenseAttribute = c.GetDefenseAttribute(this);
9927 if (defenseAttribute != null)
9928 {
9929 c.power = MathEx.ClampToInt(100L * (long)c.power / Mathf.Max(100 + defenseAttribute.Value, 1));
9930 }
9931 if (c.source.resistance.Length != 0)
9932 {
9933 int num = ResistLv(EClass.sources.elements.alias[c.source.resistance[0]].id);
9934 if (num > 0)
9935 {
9936 c.power /= num * num + 1;
9937 if (c.power <= 40)
9938 {
9939 return null;
9940 }
9941 }
9942 }
9943 c.power = c.EvaluatePower(c.power);
9944 if (c.power <= 0)
9945 {
9946 return null;
9947 }
9948 }
9949 int num2 = c.EvaluateTurn(c.power);
9950 if (c is ConDeathSentense && HasElement(494))
9951 {
9952 num2 = num2 * (100 + (int)Mathf.Sqrt(Evalue(494)) * 10) / 100;
9953 }
9954 if (num2 == 0)
9955 {
9956 return null;
9957 }
9958 for (int j = 0; j < conditions.Count; j++)
9959 {
9960 if (conditions[j].id != c.id)
9961 {
9962 continue;
9963 }
9964 if (c.Type == ConditionType.Stance || c.IsToggle)
9965 {
9966 conditions[j].Kill();
9967 return null;
9968 }
9969 if (conditions[j].CanStack(c))
9970 {
9971 if (conditions[j].ShouldOverride(c))
9972 {
9973 if (conditions[j].IsOverrideConditionMet(c, num2))
9974 {
9975 conditions[j].Kill(silent: true);
9976 continue;
9977 }
9978 return null;
9979 }
9980 if (CanGainConResist)
9981 {
9982 AddResistCon(c);
9983 }
9984 conditions[j].OnStacked(c.power);
9985 conditions[j].OnStartOrStack();
9986 conditions[j].PlayEffect();
9987 }
9988 if (!conditions[j].AllowMultipleInstance)
9989 {
9990 return null;
9991 }
9992 }
9993 foreach (Condition condition in conditions)
9994 {
9995 if (condition.TryNullify(c))
9996 {
9997 return null;
9998 }
9999 }
10000 c.value = num2;
10001 conditions.Add(c);
10002 if (CanGainConResist)
10003 {
10004 AddResistCon(c);
10005 }
10006 c.SetOwner(this);
10007 c.Start();
10008 SetDirtySpeed();
10009 if (c.ShouldRefresh)
10010 {
10011 Refresh();
10012 }
10013 if (c.CancelAI)
10014 {
10015 ai.Cancel();
10016 }
10017 if (IsPC && c.ConsumeTurn && !EClass.pc.isRestrained)
10018 {
10020 }
10021 if (c.SyncRide && (ride != null || parasite != null))
10022 {
10023 if (ride != null)
10024 {
10025 ride.AddCondition(Condition.Create(c.source.alias, c.power));
10026 }
10027 if (parasite != null)
10028 {
10029 parasite.AddCondition(Condition.Create(c.source.alias, c.power));
10030 }
10031 }
10032 return c;
10033 }
10034
10035 public override bool HasCondition<T>()
10036 {
10037 for (int i = 0; i < conditions.Count; i++)
10038 {
10039 if (conditions[i] is T)
10040 {
10041 return true;
10042 }
10043 }
10044 return false;
10045 }
10046
10047 public bool HasCondition(string alias)
10048 {
10049 for (int i = 0; i < conditions.Count; i++)
10050 {
10051 if (conditions[i].source.alias == alias)
10052 {
10053 return true;
10054 }
10055 }
10056 return false;
10057 }
10058
10059 public Element GetBuffStats(string alias)
10060 {
10061 return GetBuffStats(EClass.sources.elements.alias[alias].id);
10062 }
10063
10064 public Element GetBuffStats(int ele)
10065 {
10066 for (int i = 0; i < conditions.Count; i++)
10067 {
10068 if (conditions[i] is ConBuffStats conBuffStats && conBuffStats.refVal == ele)
10069 {
10070 return conBuffStats.elements.GetElement(ele);
10071 }
10072 }
10073 return null;
10074 }
10075
10076 public int CountDebuff()
10077 {
10078 int num = 0;
10079 foreach (Condition condition in conditions)
10080 {
10081 if (condition.Type == ConditionType.Debuff)
10082 {
10083 num++;
10084 }
10085 }
10086 return num;
10087 }
10088
10089 public void CureCondition<T>(int v = 99999) where T : Condition
10090 {
10091 T condition = GetCondition<T>();
10092 if (condition != null)
10093 {
10094 int value = condition.value - v;
10095 condition.value = value;
10096 if (condition.value <= 0)
10097 {
10098 condition.Kill();
10099 }
10100 }
10101 }
10102
10103 public BaseCondition GetCondition(string idCon)
10104 {
10105 for (int i = 0; i < conditions.Count; i++)
10106 {
10107 if (conditions[i].source.alias == idCon)
10108 {
10109 return conditions[i];
10110 }
10111 }
10112 return null;
10113 }
10114
10115 public override T GetCondition<T>()
10116 {
10117 for (int i = 0; i < conditions.Count; i++)
10118 {
10119 if (conditions[i] is T)
10120 {
10121 return conditions[i] as T;
10122 }
10123 }
10124 return null;
10125 }
10126
10127 public void RemoveCondition<T>() where T : Condition
10128 {
10129 for (int num = conditions.Count - 1; num >= 0; num--)
10130 {
10131 if (conditions[num] is T)
10132 {
10133 conditions[num].Kill();
10134 break;
10135 }
10136 }
10137 }
10138
10139 public void CureHost(CureType type, int p = 100, BlessedState state = BlessedState.Normal)
10140 {
10141 if (parasite != null)
10142 {
10143 parasite.Cure(type, p, state);
10144 }
10145 if (ride != null)
10146 {
10147 ride.Cure(type, p, state);
10148 }
10149 Cure(type, p, state);
10150 }
10151
10152 public void Cure(CureType type, int p = 100, BlessedState state = BlessedState.Normal)
10153 {
10154 bool flag = state == BlessedState.Blessed;
10155 switch (type)
10156 {
10157 case CureType.Heal:
10158 case CureType.Prayer:
10159 CureCondition<ConFear>();
10160 CureCondition<ConBlind>(2 * p / 100 + 5);
10161 CureCondition<ConPoison>(5 * p / 100 + 5);
10162 CureCondition<ConConfuse>(10 * p / 100 + 10);
10163 CureCondition<ConDim>(p / 100 + 5);
10164 CureCondition<ConBleed>(2 * p / 100 + 10);
10165 if (flag)
10166 {
10167 SAN.Mod(-15);
10168 }
10169 break;
10170 case CureType.CureBody:
10171 CureCondition<ConBlind>(5 * p / 100 + 15);
10172 CureCondition<ConPoison>(10 * p / 100 + 15);
10173 CureCondition<ConBleed>(5 * p / 100 + 20);
10174 CureTempElements(p, body: true, mind: false);
10175 break;
10176 case CureType.CureMind:
10177 CureCondition<ConFear>();
10178 CureCondition<ConDim>(3 * p / 100 + 10);
10179 CureTempElements(p, body: false, mind: true);
10180 break;
10181 case CureType.Sleep:
10182 {
10183 for (int num2 = conditions.Count - 1; num2 >= 0; num2--)
10184 {
10185 Condition condition2 = conditions[num2];
10186 if (!(condition2 is ConSleep) && !(condition2 is ConFaint))
10187 {
10188 if (condition2.isPerfume)
10189 {
10190 condition2.Mod(-1, force: true);
10191 }
10192 else if (condition2.Type == ConditionType.Bad || condition2.Type == ConditionType.Debuff)
10193 {
10194 condition2.Kill();
10195 }
10196 }
10197 }
10198 CureCondition<ConWait>();
10199 CureCondition<ConDisease>((EClass.rnd(20) + 10) * p / 100);
10200 bool flag2 = HasCondition<ConAnorexia>();
10201 base.c_vomit -= (flag2 ? 3 : 2) * p / 100;
10202 if (base.c_vomit < 0)
10203 {
10204 base.c_vomit = 0;
10205 if (flag2)
10206 {
10207 RemoveCondition<ConAnorexia>();
10208 }
10209 }
10210 break;
10211 }
10212 case CureType.HealComplete:
10213 case CureType.Death:
10214 case CureType.Jure:
10215 case CureType.Boss:
10216 case CureType.Unicorn:
10217 {
10218 CureTempElements(p * 100, body: true, mind: true);
10219 for (int num = conditions.Count - 1; num >= 0; num--)
10220 {
10221 Condition condition = conditions[num];
10222 if (condition is ConAnorexia && type != CureType.Death && type != CureType.Unicorn && type != CureType.Jure)
10223 {
10224 continue;
10225 }
10226 switch (condition.Type)
10227 {
10228 case ConditionType.Bad:
10229 case ConditionType.Debuff:
10230 case ConditionType.Disease:
10231 condition.Kill();
10232 continue;
10233 case ConditionType.Stance:
10234 if (type == CureType.Death)
10235 {
10236 condition.Kill();
10237 continue;
10238 }
10239 break;
10240 }
10241 if (type == CureType.Death && condition.isPerfume)
10242 {
10243 condition.Kill();
10244 }
10245 }
10246 CureCondition<ConWait>();
10247 CureCondition<ConSleep>();
10248 switch (type)
10249 {
10250 case CureType.Death:
10251 case CureType.Boss:
10252 case CureType.Unicorn:
10253 SAN.Mod(-20);
10254 RemoveCondition<ConBrightnessOfLife>();
10255 RemoveCondition<ConDeathSentense>();
10256 break;
10257 case CureType.Jure:
10258 SAN.Mod(-999);
10259 if (HasElement(1206))
10260 {
10261 SetFeat(1206, 0, msg: true);
10262 }
10263 RemoveCondition<ConBrightnessOfLife>();
10264 RemoveCondition<ConDeathSentense>();
10265 break;
10266 case CureType.CureBody:
10267 case CureType.CureMind:
10268 case CureType.Prayer:
10269 break;
10270 }
10271 break;
10272 }
10273 }
10274 }
10275
10276 public void RemoveAllStances()
10277 {
10278 for (int num = conditions.Count - 1; num >= 0; num--)
10279 {
10280 Condition condition = conditions[num];
10281 if (condition.Type == ConditionType.Stance)
10282 {
10283 condition.Kill();
10284 }
10285 }
10286 }
10287
10288 public bool TryNeckHunt(Chara TC, int power, bool harvest = false)
10289 {
10290 if (TC == null || TC.HasCondition<ConInvulnerable>() || TC.Evalue(1421) > 0 || !TC.ExistsOnMap)
10291 {
10292 return false;
10293 }
10294 if (TC.hp > (long)TC.MaxHP * (long)(Mathf.Min(5 + (int)Mathf.Sqrt(power), harvest ? 35 : 25) + Evalue(1426) * 5) / (TC.IsPowerful ? 200 : 100))
10295 {
10296 return false;
10297 }
10298 if (TC.HasElement(427))
10299 {
10300 return false;
10301 }
10302 if (TC.IsPC && EClass.player.invlunerable)
10303 {
10304 return false;
10305 }
10306 PlaySound("hit_finish");
10307 Say("finish");
10308 Say("finish2", this, TC);
10309 TC.DamageHP(TC.MaxHP, AttackSource.Finish, this);
10310 return false;
10311 }
10312
10313 public void AddResistCon(Condition con)
10314 {
10315 if (con.power > 0 && con.GainResistFactor > 0)
10316 {
10317 int key = con.id;
10318 if (resistCon == null)
10319 {
10320 resistCon = new Dictionary<int, int>();
10321 }
10322 if (resistCon.ContainsKey(key))
10323 {
10324 resistCon[key] += con.power * con.GainResistFactor / 100;
10325 }
10326 else
10327 {
10328 resistCon[key] = con.power * con.GainResistFactor / 100;
10329 }
10330 }
10331 }
10332
10333 public void ResistCon(Condition con)
10334 {
10335 if (con.power > 0 && resistCon != null)
10336 {
10337 int a = ClassExtension.TryGetValue<int, int>((IDictionary<int, int>)resistCon, con.id, 0);
10338 if (1000 < EClass.rnd(a))
10339 {
10340 con.power = 0;
10341 }
10342 else if (500 < EClass.rnd(a))
10343 {
10344 con.power /= 5;
10345 }
10346 else if (200 < EClass.rnd(a))
10347 {
10348 con.power /= 3;
10349 }
10350 else if (100 < EClass.rnd(a))
10351 {
10352 con.power /= 2;
10353 }
10354 }
10355 }
10356
10357 public void Sleep(Thing bed = null, Thing pillow = null, bool pickup = false, ItemPosition posBed = null, ItemPosition posPillow = null)
10358 {
10359 RemoveCondition<ConAwakening>();
10360 AddCondition(Condition.Create(100, delegate(ConSleep con)
10361 {
10362 con.pcSleep = 15;
10363 con.pcBed = bed;
10364 con.pcPillow = pillow;
10365 con.pickup = pickup;
10366 con.posBed = posBed;
10367 con.posPillow = posPillow;
10368 }), force: true);
10369 }
10370
10371 public void OnSleep(Thing bed = null, int days = 1)
10372 {
10373 bool isSunLit = pos.IsSunLit;
10374 TraitPillow traitPillow = pos.FindThing<TraitPillow>();
10375 int num = bed?.Power ?? 20;
10376 if (traitPillow != null)
10377 {
10378 num += traitPillow.owner.Power / 2;
10379 }
10380 if (bed != null)
10381 {
10382 num += bed.Evalue(750) * 5;
10383 if (bed.trait is TraitBedCoffin)
10384 {
10385 isSunLit = false;
10386 }
10387 }
10388 OnSleep(num, days, isSunLit);
10389 }
10390
10391 public void OnSleep(int power, int days = 1, bool isSunLit = false)
10392 {
10393 if (days < 1)
10394 {
10395 days = 1;
10396 }
10397 int num = power * days;
10398 if (stamina.value < 0)
10399 {
10400 stamina.Set(1);
10401 }
10402 if (IsPC)
10403 {
10405 foreach (BodySlot slot in body.slots)
10406 {
10407 if (slot.thing != null && slot.thing.GetBool(135))
10408 {
10410 slot.thing.SetBool(135, enable: false);
10411 }
10412 }
10413 }
10414 if (isWeakToSunlight && isSunLit)
10415 {
10416 base.hp = 0;
10417 if (mana.value > 0)
10418 {
10419 mana.Set(0);
10420 }
10421 AddCondition<ConBurning>(1000, force: true);
10422 }
10423 else
10424 {
10425 HealHP(num);
10426 stamina.Mod(10 + 25 * num / 100 * (100 + elements.GetFeatRef(1642)) / 100);
10427 mana.Mod(num);
10428 }
10429 if (IsPCFaction)
10430 {
10431 hunger.Mod(20);
10432 }
10433 sleepiness.Set(0);
10434 if (!IsMinion)
10435 {
10436 interest = 100;
10437 }
10438 Cure(CureType.Sleep, power);
10439 }
10440
10441 public void ModHeight(int a)
10442 {
10443 if (!HasElement(450))
10444 {
10445 long num = bio.height;
10446 num = num * (100 + a) / 100 + ((a > 0) ? 1 : (-1));
10447 if (num < 1)
10448 {
10449 num = 1L;
10450 }
10451 if (num > 999999999)
10452 {
10453 num = 999999999L;
10454 }
10455 if (num != bio.height)
10456 {
10457 bio.height = (int)num;
10458 Say((a > 0) ? "height_gain" : "height_lose", this);
10459 }
10460 }
10461 }
10462
10463 public void ModWeight(int a, bool ignoreLimit = false)
10464 {
10465 if (HasElement(450) || a == 0)
10466 {
10467 return;
10468 }
10469 long num = bio.weight;
10470 long num2 = bio.height;
10471 long num3 = num2 * num2 * 18 / 25000;
10472 long num4 = num2 * num2 * 24 / 10000;
10473 if (ignoreLimit || (num > num3 && num < num4))
10474 {
10475 num = num * (100 + a) / 100 + ((a > 0) ? 1 : (-1));
10476 if (num < 1)
10477 {
10478 num = 1L;
10479 }
10480 if (num > 999999999)
10481 {
10482 num = 999999999L;
10483 }
10484 if (num != bio.weight)
10485 {
10486 bio.weight = (int)num;
10487 Say((a > 0) ? "weight_gain" : "weight_lose", this);
10488 }
10489 }
10490 }
10491
10492 public void ModCorruption(int a)
10493 {
10494 if (a > 0)
10495 {
10496 if (Evalue(962) >= 25 || (ResistLv(962) > 0 && EClass.rnd(ResistLv(962) + 1) != 0))
10497 {
10498 return;
10499 }
10500 int num = Evalue(412);
10501 if (num != 0)
10502 {
10503 float num2 = (float)a * 100f / (float)Mathf.Max(100 + num * 2, 10);
10504 a = (int)num2 + ((EClass.rndf(1f) < num2 % 1f) ? 1 : 0);
10505 }
10506 }
10507 if (a == 0)
10508 {
10509 return;
10510 }
10511 int num3 = (corruption + a) / 100 - corruption / 100;
10512 for (int i = 0; i < Mathf.Abs(num3); i++)
10513 {
10514 if (!MutateRandom((num3 > 0) ? 1 : (-1), 100, ether: true))
10515 {
10516 break;
10517 }
10518 }
10519 corruption += a;
10520 int num4 = 0;
10521 foreach (Element value in elements.dict.Values)
10522 {
10523 if (value.source.category == "ether")
10524 {
10525 num4 += value.Value;
10526 }
10527 }
10528 if (num4 > 0 && IsPC)
10529 {
10530 Tutorial.Reserve("ether");
10531 }
10532 corruption = num4 * 100 + corruption % 100;
10533 }
10534
10535 public List<Element> ListAvailabeFeats(bool pet = false, bool showAll = false, bool purchaseFeat = false)
10536 {
10537 List<Element> list = new List<Element>();
10538 foreach (SourceElement.Row item in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.group == "FEAT" && a.cost[0] != -1 && !a.categorySub.IsEmpty()))
10539 {
10540 Feat feat = elements.GetOrCreateElement(item.id) as Feat;
10541 int num = ((feat.ValueWithoutLink <= 0) ? 1 : (feat.ValueWithoutLink + 1));
10542 if (purchaseFeat)
10543 {
10544 num -= feat.GetDNABonus(this);
10545 }
10546 if (num <= feat.source.max && !feat.HasTag("class") && !feat.HasTag("hidden") && !feat.HasTag("innate") && (!pet || !feat.HasTag("noPet")) && (showAll || feat.IsPurchaseFeatReqMet(elements)))
10547 {
10548 list.Add(Element.Create(feat.id, num) as Feat);
10549 }
10550 }
10551 return list;
10552 }
10553
10554 public void SetFeat(int id, int value = 1, bool msg = false)
10555 {
10556 Feat feat = elements.GetElement(id) as Feat;
10557 int num = 0;
10558 if (feat != null && feat.Value > 0)
10559 {
10560 if (value == feat.Value)
10561 {
10562 return;
10563 }
10564 num = feat.Value;
10565 feat.Apply(-feat.Value, elements);
10566 }
10567 feat = elements.SetBase(id, value - (feat?.vSource ?? 0)) as Feat;
10568 if (feat != null && feat.Value != 0)
10569 {
10570 feat.Apply(feat.Value, elements);
10571 }
10573 {
10574 Refresh();
10575 CalculateMaxStamina();
10576 }
10577 if (!msg)
10578 {
10579 return;
10580 }
10581 if (feat != null)
10582 {
10583 if (feat.source.textInc.IsEmpty())
10584 {
10585 PlaySound("ding_skill");
10587 Say("gainFeat", this, feat.FullName);
10588 }
10589 else
10590 {
10591 bool flag = value < num;
10592 if (feat.source.tag.Contains("neg"))
10593 {
10594 flag = !flag;
10595 }
10596 switch (id)
10597 {
10598 case 1270:
10599 if (!flag)
10600 {
10601 PlaySound("chime_angel");
10602 }
10603 break;
10604 case 1271:
10605 if (!flag)
10606 {
10607 PlaySound("chime_devil");
10608 }
10609 break;
10610 default:
10611 PlaySound("mutation");
10612 break;
10613 }
10615 Say((value > num) ? feat.source.GetText("textInc") : feat.source.GetText("textDec"), this, feat.FullName);
10616 }
10617 }
10618 elements.CheckSkillActions();
10619 }
10620
10621 public void SetMutation(int idEle, int a = 0)
10622 {
10623 SourceElement.Row row = EClass.sources.elements.map[idEle];
10625 Element element = elements.GetElement(idEle);
10626 Element element2 = elements.GetElement(row2.id);
10627 int num = element?.Value ?? 0;
10628 if (a < 0)
10629 {
10630 a = 0;
10631 }
10632 if (a > row.max)
10633 {
10634 a = row.max;
10635 }
10636 bool flag = (row.tag.Contains("neg") ? (a > num) : (a < num));
10637 if (a == 0 && (element == null || element.Value == 0))
10638 {
10639 SayNothingHappans();
10640 return;
10641 }
10642 if (element != null && element.Value == a)
10643 {
10644 SayNothingHappans();
10645 return;
10646 }
10647 if (element2 != null && element2.Value > 0)
10648 {
10649 SetFeat(element2.id, 0);
10650 }
10651 SetFeat(idEle, a);
10652 PlaySound("mutation");
10653 PlayEffect("mutation");
10655 Say(row.GetText(flag ? "textDec" : "textInc", returnNull: true) ?? row.alias, this);
10656 }
10657
10658 public bool MutateRandom(int vec = 0, int tries = 100, bool ether = false, BlessedState state = BlessedState.Normal)
10659 {
10660 if (!ether && vec >= 0 && HasElement(406) && EClass.rnd(5) != 0)
10661 {
10662 Say("resistMutation", this);
10663 return false;
10664 }
10665 IEnumerable<SourceElement.Row> ie = EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == (ether ? "ether" : "mutation") && !a.tag.Contains("noRandomMutation"));
10666 for (int num = 0; num < tries; num++)
10667 {
10668 SourceElement.Row row = ie.RandomItem();
10669 if (num == 0 && vec < 0 && ether && base.c_corruptionHistory != null && base.c_corruptionHistory.Count > 0)
10670 {
10671 if (EClass.sources.elements.map.ContainsKey(base.c_corruptionHistory.LastItem()))
10672 {
10673 row = EClass.sources.elements.map[base.c_corruptionHistory.LastItem()];
10674 }
10675 base.c_corruptionHistory.RemoveAt(base.c_corruptionHistory.Count - 1);
10676 if (base.c_corruptionHistory.Count == 0)
10677 {
10678 base.c_corruptionHistory = null;
10679 }
10680 }
10681 Element element = elements.GetElement(row.id);
10682 int num2 = 1;
10683 if ((vec > 0 && ((row.id == 1563 && corruption < 300) || (row.id == 1562 && corruption < 1000 && base.IsPowerful))) || (vec < 0 && (element == null || element.Value <= 0)) || (vec > 0 && element != null && element.Value >= row.max))
10684 {
10685 continue;
10686 }
10687 if (element == null && !row.aliasParent.IsEmpty() && elements.Has(row.aliasParent))
10688 {
10689 row = EClass.sources.elements.alias[row.aliasParent];
10690 element = elements.GetElement(row.id);
10691 }
10692 bool flag = row.tag.Contains("neg");
10693 if (vec > 0)
10694 {
10695 if ((state >= BlessedState.Blessed && flag) || (state <= BlessedState.Cursed && !flag))
10696 {
10697 continue;
10698 }
10699 }
10700 else if (vec < 0 && ((state >= BlessedState.Blessed && !flag) || (state <= BlessedState.Cursed && flag)))
10701 {
10702 continue;
10703 }
10704 bool flag2 = true;
10705 if (element != null)
10706 {
10707 num2 = element.Value + ((vec != 0) ? vec : ((EClass.rnd(2) == 0) ? 1 : (-1)));
10708 if (num2 > element.source.max)
10709 {
10710 num2 = element.source.max - 1;
10711 }
10712 flag = (flag && num2 > element.Value) || (!flag && num2 < element.Value);
10713 flag2 = num2 > element.Value;
10714 if (vec > 0 && !flag2)
10715 {
10716 continue;
10717 }
10718 }
10719 Say(flag2 ? "mutation_gain" : "mutation_loose", this);
10720 SetFeat(row.id, num2);
10721 if (flag2 && ether)
10722 {
10723 if (base.c_corruptionHistory == null)
10724 {
10725 base.c_corruptionHistory = new List<int>();
10726 }
10727 base.c_corruptionHistory.Add(row.id);
10728 if (IsPCFaction)
10729 {
10730 Element element2 = elements.GetElement(row.id);
10731 WidgetPopText.Say("popEther".lang(element2.Name, base.Name));
10732 }
10733 if (IsPC && !EClass.player.flags.gotEtherDisease)
10734 {
10735 EClass.player.flags.gotEtherDisease = true;
10736 Thing thing = ThingGen.Create("parchment");
10737 thing.SetStr(53, "letter_ether");
10738 Thing thing2 = ThingGen.Create("1165");
10739 thing2.SetBlessedState(BlessedState.Normal);
10740 Thing p = ThingGen.CreateParcel(null, thing2, thing);
10742 }
10743 }
10744 if (EClass.core.IsGameStarted && pos != null)
10745 {
10746 PlaySound(ether ? "mutation_ether" : "mutation");
10747 PlayEffect("mutation");
10749 Say(row.GetText(flag ? "textDec" : "textInc", returnNull: true) ?? row.alias, this);
10750 }
10751 return true;
10752 }
10753 Say("nothingHappens");
10754 return false;
10755 }
10756
10757 public void GainAbility(int ele, int mtp = 100, Thing origin = null)
10758 {
10759 Element orCreateElement = elements.GetOrCreateElement(ele);
10760 if (orCreateElement.ValueWithoutLink == 0)
10761 {
10762 elements.ModBase(orCreateElement.id, 1);
10763 }
10764 if (orCreateElement is Spell)
10765 {
10766 int num = EClass.curve(Evalue(307), 50, 20) + (HasElement(307) ? 20 : 0);
10767 int num2 = origin?.Evalue(765) ?? 0;
10768 num = num * (100 - num2) / 100;
10769 int a = mtp * orCreateElement.source.charge * (100 + num) / 100 / 100;
10770 a = Mathf.Max(1, EClass.rndHalf(a));
10771 if (orCreateElement.source.charge == 1)
10772 {
10773 a = 1;
10774 }
10775 orCreateElement.vPotential += a;
10776 }
10777 Say("spell_gain", this, orCreateElement.Name);
10778 LayerAbility.SetDirty(orCreateElement);
10779 }
10780
10781 public bool TryNullifyCurse()
10782 {
10783 if (IsPCParty)
10784 {
10785 foreach (Chara member in EClass.pc.party.members)
10786 {
10787 if (member.HasElement(1641) && EClass.rnd(3) != 0)
10788 {
10789 Msg.Say("curse_nullify", member);
10790 return true;
10791 }
10792 }
10793 }
10794 else if (HasElement(1641) && EClass.rnd(3) != 0)
10795 {
10796 Say("curse_nullify", this);
10797 return true;
10798 }
10799 if (GetCondition<ConHolyVeil>() != null && EClass.rnd(5) != 0)
10800 {
10801 Say("curse_nullify", this);
10802 return true;
10803 }
10804 return false;
10805 }
10806
10807 public void OnAdvanceDay()
10808 {
10809 if (_historyFood != null)
10810 {
10811 while (_historyFood.Count > 5)
10812 {
10813 _historyFood.RemoveAt(_historyFood.Count - 1);
10814 }
10815 if (_historyFood[0].Count > 0)
10816 {
10817 _historyFood.Insert(0, new List<string>());
10818 }
10819 }
10820 }
10821
10823 {
10824 if (!IsPCFaction || !IsGlobal)
10825 {
10826 _historyFood = null;
10827 return;
10828 }
10829 if (_historyFood == null)
10830 {
10831 _historyFood = new List<List<string>>
10832 {
10833 new List<string>()
10834 };
10835 }
10836 if (_historyFood[0].Count < 5)
10837 {
10838 _historyFood[0].Add(food.id);
10839 }
10840 }
10841
10843 {
10844 if (_historyFood == null)
10845 {
10846 return -1;
10847 }
10848 int num = 0;
10849 foreach (List<string> item in _historyFood)
10850 {
10851 foreach (string item2 in item)
10852 {
10853 if (item2 == food.id)
10854 {
10855 num++;
10856 }
10857 }
10858 }
10859 return num;
10860 }
10861
10862 public int GetPietyValue()
10863 {
10864 if (base._IsPC)
10865 {
10866 return 10 + (int)(Mathf.Sqrt(base.c_daysWithGod) * 2f + (float)Evalue(85)) / 2;
10867 }
10868 return 10 + (int)(Mathf.Sqrt(base.LV) * 5f + (float)Evalue(306)) / 2;
10869 }
10870
10872 {
10873 if (faithElements != null)
10874 {
10875 faithElements.SetParent();
10876 }
10877 faithElements = new ElementContainer();
10878 if (idFaith == "eyth" && !HasElement(1228))
10879 {
10880 return;
10881 }
10882 SourceReligion.Row row = EClass.sources.religions.map.TryGetValue(idFaith);
10883 if (row == null)
10884 {
10885 return;
10886 }
10887 faithElements = new ElementContainer();
10888 if (!HasCondition<ConExcommunication>())
10889 {
10890 SourceElement.Row row2 = EClass.sources.elements.alias.TryGetValue("featGod_" + row.id + "1");
10891 if (row2 != null)
10892 {
10893 faithElements.SetBase(row2.id, 1);
10894 }
10895 int[] array = row.elements;
10896 int num = GetPietyValue() * (120 + Evalue(1407) * 15 + Evalue(1228) * 20) / 100;
10897 for (int i = 0; i < array.Length; i += 2)
10898 {
10899 int num2 = array[i + 1] * num / 50;
10900 if (array[i] == 79)
10901 {
10902 num2 = EClass.curve(num2, array[i + 1] * 2, 10, 50);
10903 }
10904 if (num2 >= 20 && array[i] >= 950 && array[i] < 970)
10905 {
10906 num2 = 20;
10907 }
10908 faithElements.SetBase(array[i], Mathf.Max(num2, 1));
10909 }
10910 }
10911 faithElements.SetParent(this);
10912 }
10913
10914 public void ModTempElement(int ele, int a, bool naturalDecay = false, bool onlyRenew = false)
10915 {
10916 if (a < 0 && !naturalDecay && HasElement(EClass.sources.elements.alias["sustain_" + EClass.sources.elements.map[ele].alias]?.id ?? 0))
10917 {
10918 return;
10919 }
10920 bool flag = HasElement(1215);
10921 if (tempElements == null)
10922 {
10923 tempElements = new ElementContainer();
10924 tempElements.SetParent(this);
10925 }
10926 if (a > 0 && flag)
10927 {
10928 a = a * 150 / 100;
10929 }
10930 int num = elements.ValueWithoutLink(ele);
10931 int num2 = Mathf.Abs(num) + 100;
10932 int num3 = num2 / (flag ? 2 : 4);
10933 int num4 = -num - 100;
10934 int num5 = tempElements.Base(ele);
10935 int num6 = num5 + a;
10936 if (onlyRenew)
10937 {
10938 num3 = Mathf.Min(a, num3);
10939 num4 = Mathf.Max(a, -num2 / 3);
10940 }
10941 if (a > 0 && num6 > num3)
10942 {
10943 a = ((num3 > num5) ? (num3 - num5) : 0);
10944 }
10945 if (a < 0 && num6 < num4)
10946 {
10947 a = ((num4 < num5) ? (num4 - num5) : 0);
10948 }
10949 Element element = tempElements.ModBase(ele, a);
10950 if (element.vBase == 0)
10951 {
10952 tempElements.Remove(element.id);
10953 if (tempElements.dict.Count == 0)
10954 {
10955 tempElements = null;
10956 }
10957 }
10958 }
10959
10960 public void DamageTempElements(int p, bool body, bool mind, bool onlyRenew = false)
10961 {
10962 if (body)
10963 {
10964 DamageTempElement(Element.List_Body.RandomItem(), p, onlyRenew);
10965 }
10966 if (mind)
10967 {
10968 DamageTempElement(Element.List_Mind.RandomItem(), p, onlyRenew);
10969 }
10970 }
10971
10972 public void DamageTempElement(int ele, int p, bool onlyRenew = false)
10973 {
10974 ModTempElement(ele, onlyRenew ? (-p / 20) : (-(p / 100 + EClass.rnd(p / 100 + 1) + 1)), naturalDecay: false, onlyRenew);
10975 }
10976
10977 public void EnhanceTempElements(int p, bool body, bool mind, bool onlyRenew = false)
10978 {
10979 int[] array = (body ? Element.List_Body : Element.List_Mind);
10980 foreach (int ele in array)
10981 {
10982 EnhanceTempElement(ele, p, onlyRenew);
10983 }
10984 }
10985
10986 public void EnhanceTempElement(int ele, int p, bool onlyRenew = false)
10987 {
10988 ModTempElement(ele, onlyRenew ? (p / 20) : (p / 100 + EClass.rnd(p / 100 + 1)), naturalDecay: false, onlyRenew);
10989 }
10990
10991 public void DiminishTempElements(int a = 1)
10992 {
10993 if (tempElements == null)
10994 {
10995 return;
10996 }
10997 foreach (Element item in tempElements.dict.Values.ToList())
10998 {
10999 if (item.vBase > 0)
11000 {
11001 ModTempElement(item.id, -Mathf.Min(item.vBase * 5 / 100 + 1, item.vBase), naturalDecay: true);
11002 }
11003 }
11004 }
11005
11006 public void CureTempElements(int p, bool body, bool mind)
11007 {
11008 if (tempElements != null)
11009 {
11010 if (body)
11011 {
11012 Cure(Element.List_Body);
11013 }
11014 if (mind)
11015 {
11016 Cure(Element.List_Mind);
11017 }
11018 }
11019 void Cure(int[] eles)
11020 {
11021 foreach (int ele in eles)
11022 {
11023 if (tempElements == null)
11024 {
11025 break;
11026 }
11027 Element element = tempElements.GetElement(ele);
11028 if (element != null && element.vBase < 0)
11029 {
11030 ModTempElement(ele, Mathf.Clamp(p / 20 + EClass.rnd(p / 20), 1, -element.vBase));
11031 }
11032 }
11033 }
11034 }
11035
11036 public void ClearTempElements()
11037 {
11038 if (tempElements != null)
11039 {
11040 tempElements.SetParent();
11041 tempElements = null;
11042 }
11043 }
11044}
AnimeID
Definition: AnimeID.cs:2
AttackSource
Definition: AttackSource.cs:2
AttackStyle
Definition: AttackStyle.cs:2
BlessedState
Definition: BlessedState.cs:2
BossType
Definition: BossType.cs:2
CTAG
Definition: CTAG.cs:2
@ ride
@ currency
ClearInventoryType
ConditionType
Definition: ConditionType.cs:2
ContainerFlag
Definition: ContainerFlag.cs:5
CureType
Definition: CureType.cs:2
CurrencyType
Definition: CurrencyType.cs:2
if(!match.Success)
DuplicateCondition
EditorTag
Definition: EditorTag.cs:2
EffectId
Definition: EffectId.cs:2
@ ChangeMaterial
Emo2
Definition: Emo2.cs:2
Emo
Definition: Emo.cs:2
@ harvest
ExpeditionType
FactionMemberType
FontColor
Definition: FontColor.cs:2
GoalListType
Definition: GoalListType.cs:2
Hostility
Definition: Hostility.cs:2
IDTSource
Definition: IDTSource.cs:2
ID_Achievement
MinionType
Definition: MinionType.cs:2
NameStyle
Definition: NameStyle.cs:2
PlaceState
Definition: PlaceState.cs:2
PriceType
Definition: PriceType.cs:2
Rarity
Definition: Rarity.cs:2
Ridability
Definition: Ridability.cs:2
ShopType
Definition: ShopType.cs:2
SourceValueType
TreasureType
Definition: TreasureType.cs:2
WitnessType
Definition: WitnessType.cs:2
Definition: ACT.cs:6
static Act Create(int id)
Definition: ACT.cs:36
Definition: AIAct.cs:6
Status Tick()
Definition: AIAct.cs:366
virtual bool IsIdle
Definition: AIAct.cs:78
AIAct Current
Definition: AIAct.cs:103
bool TryCancel(Card c)
Definition: AIAct.cs:280
bool IsMoveAI
Definition: AIAct.cs:55
virtual bool IsRunning
Definition: AIAct.cs:31
virtual bool PushChara
Definition: AIAct.cs:82
virtual Status Cancel()
Definition: AIAct.cs:305
virtual bool ShouldAllyAttack(Chara tg)
Definition: AIAct.cs:134
virtual bool IsNoGoal
Definition: AIAct.cs:74
virtual bool CancelOnAggro
Definition: AIAct.cs:80
void SetOwner(Chara c)
Definition: AIAct.cs:189
override string ToString()
Definition: AIAct.cs:124
virtual bool CancelWhenMoved
Definition: AIAct.cs:96
string GetCurrentActionText()
Definition: AIAct.cs:157
virtual Point GetDestination()
Definition: AIAct.cs:139
Definition: AIWork.cs:6
Thing destThing
Definition: AIWork.cs:17
bool SetDestination()
Definition: AIWork.cs:56
virtual void OnPerformWork(bool realtime)
Definition: AIWork.cs:155
BaseArea destArea
Definition: AIWork.cs:13
Definition: AI_Eat.cs:5
static bool slaughtering
Definition: AI_Slaughter.cs:6
bool TryCancelInteraction(bool sound=true)
Definition: AM_Adv.cs:1120
void SetTurbo(int mtp=-1)
Definition: AM_Adv.cs:1091
static void ProcAt(EffectId id, int power, BlessedState state, Card cc, Card tc, Point tp, bool isNeg, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:519
List< Item > items
Definition: ActList.cs:14
static void Unride(Chara host, Chara mount, bool talk=true)
Definition: ActRide.cs:107
static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method=ThrowMethod.Default, float failChance=0f)
Definition: ActThrow.cs:97
static void Search(Chara c, bool manual=false)
Definition: ActWait.cs:46
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
virtual bool Perform()
Definition: ACT.cs:266
virtual TargetType TargetType
Definition: ACT.cs:144
virtual float RapidDelay
Definition: ACT.cs:177
virtual bool ValidatePerform(Chara _cc, Card _tc, Point _tp)
Definition: ACT.cs:321
bool IsTargetHostileParty()
Definition: ACT.cs:241
virtual bool CanRapidFire
Definition: ACT.cs:175
static AM_Sim Sim
Definition: ActionMode.cs:11
static AM_Adv Adv
Definition: ActionMode.cs:15
static Affinity Get(Chara c)
Definition: Affinity.cs:38
int Mod(int a)
Definition: Affinity.cs:212
Stage CurrentStage
Definition: Affinity.cs:32
bool CanSleepBeside()
Definition: Affinity.cs:88
int GetLunchChance()
Definition: Affinity.cs:97
bool CanGiveCard()
Definition: Affinity.cs:70
bool IsWeddingHater
Definition: Affinity.cs:36
Thing OnGift(Thing t)
Definition: Affinity.cs:140
static int indexSister
virtual bool IsToggle
virtual RendererReplacer GetRendererReplacer()
virtual bool PreventRegen
virtual int EvaluatePower(int p)
virtual int GainResistFactor
virtual bool TryMove(Point p)
virtual bool ConsumeTurn
Element GetDefenseAttribute(Chara c=null)
virtual int EvaluateTurn(int p)
virtual bool TimeBased
virtual void OnRefresh()
void Mod(int a, bool force=false)
virtual void SetOwner(Chara _owner, bool onDeserialize=false)
virtual bool TryNullify(Condition c)
virtual void OnEndPlayerTurn()
virtual ConditionType Type
Definition: BaseStats.cs:33
virtual string GetPhaseStr()
Definition: BaseStats.cs:61
SourceStat.Row source
Definition: BaseStats.cs:16
virtual Emo2 EmoIcon
Definition: BaseStats.cs:31
int id
Definition: BaseStats.cs:11
virtual int GetValue()
Definition: BaseStats.cs:66
static int GetColorInt(ref Color matColor, int p)
void SetGender(int g)
Definition: Biography.cs:469
int weight
Definition: Biography.cs:41
void Generate(Chara c)
Definition: Biography.cs:323
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
virtual bool isPCC
Definition: CardActor.cs:41
static void Set(CardBlueprint _bp=null)
static CardBlueprint CharaGenEQ
Chara Find(string id)
Definition: CardManager.cs:20
GlobalCharaList globalCharas
Definition: CardManager.cs:46
void PlayAnime(AnimeID id, bool force)
RendererReplacer replacer
Definition: CardRenderer.cs:29
Vector3 position
Definition: CardRenderer.cs:21
TransAnime anime
Definition: CardRenderer.cs:23
virtual void NextFrame()
void RefreshExtra()
CardActor actor
Definition: CardRenderer.cs:11
string id
Definition: CardRow.cs:7
Definition: Card.cs:11
bool IsNegativeGift
Definition: Card.cs:2466
bool isDestroyed
Definition: Card.cs:78
MinionType c_minionType
Definition: Card.cs:1015
int FameLv
Definition: Card.cs:2368
virtual string GetName(NameStyle style, int num=-1)
Definition: Card.cs:2748
bool IsPCFactionOrMinion
Definition: Card.cs:2342
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:6194
bool IsDecayed
Definition: Card.cs:2357
virtual bool isThing
Definition: Card.cs:2133
bool IsAmmo
Definition: Card.cs:2301
bool isSummon
Definition: Card.cs:713
virtual Chara Chara
Definition: Card.cs:2122
Thing Split(int a)
Definition: Card.cs:3665
int EvalueMax(int ele, int min=0)
Definition: Card.cs:2718
void MakeFigureFrom(string id)
Definition: Card.cs:6022
ElementContainerCard elements
Definition: Card.cs:42
string id
Definition: Card.cs:36
bool isNPCProperty
Definition: Card.cs:557
int GetSightRadius()
Definition: Card.cs:6900
bool IsUnique
Definition: Card.cs:2143
Hostility c_originalHostility
Definition: Card.cs:1003
bool isRestrained
Definition: Card.cs:569
bool IsThrownWeapon
Definition: Card.cs:2299
int ExpToNext
Definition: Card.cs:2060
CardBlueprint bp
Definition: Card.cs:80
SourceMaterial.Row material
Definition: Card.cs:2103
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6645
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3217
bool isCopy
Definition: Card.cs:881
void SetInt(string id, int value=0)
Definition: Card.cs:2586
Card MakeRefFrom(string id)
Definition: Card.cs:6027
void ClampInitialSkill()
Definition: Card.cs:3115
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:7781
int c_lockLv
Definition: Card.cs:991
bool ignoreAutoPick
Definition: Card.cs:509
int GetEquipValue()
Definition: Card.cs:7678
Fov fov
Definition: Card.cs:58
int invY
Definition: Card.cs:2007
virtual CardRenderer _CreateRenderer()
Definition: Card.cs:6440
bool IsCursed
Definition: Card.cs:2309
int c_uidMaster
Definition: Card.cs:1489
Biography bio
Definition: Card.cs:45
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3280
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:7206
Card SetLv(int a)
Definition: Card.cs:3070
Rarity rarity
Definition: Card.cs:317
string Name
Definition: Card.cs:2191
bool IsRangedWeapon
Definition: Card.cs:2297
int CHA
Definition: Card.cs:2417
ICardParent parent
Definition: Card.cs:56
bool ExistsOnMap
Definition: Card.cs:2137
bool IsHotItem
Definition: Card.cs:122
Thing SetNum(int a)
Definition: Card.cs:3676
void SetReplica(bool on)
Definition: Card.cs:3251
bool IsFood
Definition: Card.cs:2229
PlaceState placeState
Definition: Card.cs:86
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:4076
bool isAcidproof
Definition: Card.cs:689
bool HasTag(CTAG tag)
Definition: Card.cs:2728
Point pos
Definition: Card.cs:60
void DyeRandom()
Definition: Card.cs:6473
int uid
Definition: Card.cs:125
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6679
bool IsEquipmentOrRanged
Definition: Card.cs:2272
void TryStack(Thing t)
Definition: Card.cs:7484
void ShowEmo(Emo _emo=Emo.none, float duration=0f, bool skipSame=true)
Definition: Card.cs:6613
Trait trait
Definition: Card.cs:54
void ModCurrency(int a, string id="money")
Definition: Card.cs:4142
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2179
MoveType
Definition: Card.cs:21
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4276
bool isNew
Definition: Card.cs:485
void Destroy()
Definition: Card.cs:5314
bool c_isImportant
Definition: Card.cs:1051
MoveResult
Definition: Card.cs:13
bool noMove
Definition: Card.cs:773
bool HaveFur()
Definition: Card.cs:8439
void SetStr(string id, string value=null)
Definition: Card.cs:2600
ThingContainer things
Definition: Card.cs:39
BossType c_bossType
Definition: Card.cs:1261
bool IsInstalled
Definition: Card.cs:2451
bool IsMeleeWeapon
Definition: Card.cs:2295
virtual bool isChara
Definition: Card.cs:2135
virtual Thing Thing
Definition: Card.cs:2110
Card GetRootCard()
Definition: Card.cs:3607
int Evalue(int ele)
Definition: Card.cs:2704
bool GetBool(string id)
Definition: Card.cs:2557
int Dist(Card c)
Definition: Card.cs:8229
bool isHidden
Definition: Card.cs:533
virtual bool IsPCFaction
Definition: Card.cs:2339
bool isGifted
Definition: Card.cs:785
BlessedState blessedState
Definition: Card.cs:281
Thing Duplicate(int num)
Definition: Card.cs:3625
int _colorInt
Definition: Card.cs:70
bool isScaled
Definition: Card.cs:917
bool TryStackTo(Thing to)
Definition: Card.cs:3578
virtual bool IsPCFactionMinion
Definition: Card.cs:2209
Card Install()
Definition: Card.cs:3922
void ApplyBacker(int bid)
Definition: Card.cs:7501
Card parentCard
Definition: Card.cs:106
void ModExp(string alias, int a)
Definition: Card.cs:2781
string c_idRefName
Definition: Card.cs:1681
int GetLightRadius()
Definition: Card.cs:6909
int genLv
Definition: Card.cs:197
int Num
Definition: Card.cs:161
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:6664
SourceCategory.Row category
Definition: Card.cs:2101
void SetBool(string id, bool enable)
Definition: Card.cs:2562
void ModNum(int a, bool notify=true)
Definition: Card.cs:3696
virtual RenderRow TileRow
Definition: Card.cs:2187
bool isLeashed
Definition: Card.cs:845
bool IsIdentified
Definition: Card.cs:2447
bool IsContainer
Definition: Card.cs:2141
int c_charges
Definition: Card.cs:1309
CardRenderer renderer
Definition: Card.cs:64
void AddExp(int a, bool applyMod=true)
Definition: Card.cs:3123
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6383
int LV
Definition: Card.cs:389
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7324
string c_idRefCard
Definition: Card.cs:1777
int c_uidAttune
Definition: Card.cs:1212
Thing MakeEgg(bool effect=true, int num=1, bool addToZone=true, int fertChance=20, BlessedState? state=null)
Definition: Card.cs:6045
List< Chara > charas
Definition: CellDetail.cs:13
bool isHostileAct
Definition: CellEffect.cs:74
EffectId idEffect
Definition: CellEffect.cs:38
bool isCursed
Definition: CellEffect.cs:98
SourceCellEffect.Row source
Definition: CellEffect.cs:145
bool isBlessed
Definition: CellEffect.cs:86
Definition: Cell.cs:7
Room room
Definition: Cell.cs:122
SourceBlock.Row sourceBlock
Definition: Cell.cs:1090
bool IsSnowTile
Definition: Cell.cs:818
SourceFloor.Row sourceFloor
Definition: Cell.cs:1092
CellEffect effect
Definition: Cell.cs:114
int obj
Definition: Cell.cs:50
bool hasDoorBoat
Definition: Cell.cs:510
bool HasBridge
Definition: Cell.cs:707
bool IsTopWaterAndNoSnow
Definition: Cell.cs:748
bool isClearSnow
Definition: Cell.cs:462
bool isFloating
Definition: Cell.cs:486
SourceMaterial.Row matObj
Definition: Cell.cs:1074
byte topHeight
Definition: Cell.cs:100
byte light
Definition: Cell.cs:80
SourceFloor.Row sourceBridge
Definition: Cell.cs:1094
bool IsSky
Definition: Cell.cs:970
byte z
Definition: Cell.cs:78
bool HasRoof
Definition: Cell.cs:684
SourceMaterial.Row matFloor
Definition: Cell.cs:1068
bool isSeen
Definition: Cell.cs:294
SourceObj.Row sourceObj
Definition: Cell.cs:1112
byte x
Definition: Cell.cs:76
bool HasRamp
Definition: Cell.cs:873
bool hasDoor
Definition: Cell.cs:279
SourceFloor.Row sourceSurface
Definition: Cell.cs:1097
float GetSurfaceHeight()
Definition: Cell.cs:1766
bool CanSuffocate()
Definition: Cell.cs:1151
ActList list
Definition: CharaAbility.cs:13
bool Has(int id)
bool HasWeapon()
Definition: CharaBody.cs:429
void RemoveBodyPartAt(int idx)
Definition: CharaBody.cs:373
void SetOwner(Chara chara, bool deserialized=false)
Definition: CharaBody.cs:18
void AddBodyPart(int ele, Thing thing=null)
Definition: CharaBody.cs:312
bool HasElement(int idEle)
Definition: CharaBody.cs:441
List< BodySlot > slots
Definition: CharaBody.cs:8
BodySlot slotMainHand
Definition: CharaBody.cs:10
bool IsTooHeavyToEquip(Thing thing)
Definition: CharaBody.cs:187
AttackStyle GetAttackStyle()
Definition: CharaBody.cs:508
bool IsEquippable(Thing thing, BodySlot slot, bool text=true)
Definition: CharaBody.cs:114
int GetWeight(bool armorOnly=false)
Definition: CharaBody.cs:465
bool Equip(Thing thing, BodySlot slot=null, bool msg=true)
Definition: CharaBody.cs:213
BodySlot GetSlot(Thing t, bool onlyEmpty=false, bool secondSlot=false)
Definition: CharaBody.cs:398
void RefreshBodyParts()
Definition: CharaBody.cs:338
void RemoveBodyPart(int ele)
Definition: CharaBody.cs:367
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
override void SetOwner(Card c)
PCCData pccData
Definition: Chara.cs:10
void OnInsulted()
Definition: Chara.cs:8728
SourceCategory.Row GetFavCat()
Definition: Chara.cs:8577
void GetRevived()
Definition: Chara.cs:5476
string[] _strs
Definition: Chara.cs:79
bool IsHumanSpeak
Definition: Chara.cs:1062
void DamageTempElement(int ele, int p, bool onlyRenew=false)
Definition: Chara.cs:10972
Stats depression
Definition: Chara.cs:1207
bool UseAbility(string idAct, Card tc=null, Point pos=null, bool pt=false)
Definition: Chara.cs:6166
void Refresh(bool calledRecursive=false)
Definition: Chara.cs:1804
void ChangeRace(string idNew)
Definition: Chara.cs:2507
override SourcePref Pref
Definition: Chara.cs:805
bool HasHobbyOrWork(string alias)
Definition: Chara.cs:9451
static List< Chara > _pts
Definition: Chara.cs:190
string IDPCCBodySet
Definition: Chara.cs:495
void TickConditions()
Definition: Chara.cs:3940
override string actorPrefab
Definition: Chara.cs:525
bool wasInWater
Definition: Chara.cs:150
void UpdateSight()
Definition: Chara.cs:3912
int _affinity
Definition: Chara.cs:307
Stats sleepiness
Definition: Chara.cs:1215
static Point _sharedPos
Definition: Chara.cs:178
override bool IsAliveInCurrentZone
Definition: Chara.cs:567
void SetDirtySpeed()
Definition: Chara.cs:2069
bool IsFriendOrAbove(Chara c)
Definition: Chara.cs:7047
int GetBurden(Card t=null, int num=-1)
Definition: Chara.cs:2018
override void ApplyEditorTags(EditorTag tag)
Definition: Chara.cs:2251
BaseCondition GetCondition(string idCon)
Definition: Chara.cs:10103
Element MainElement
Definition: Chara.cs:735
Thing FindBestFoodToEat()
Definition: Chara.cs:8043
new TraitChara trait
Definition: Chara.cs:509
Hostility OriginalHostility
Definition: Chara.cs:475
void ResetBody()
Definition: Chara.cs:2441
CharaBody body
Definition: Chara.cs:94
void TryPickGroundItem(Func< Card, bool > func=null)
Definition: Chara.cs:4724
LayerDrama _ShowDialog(string book, string sheet, string step="main", string tag="")
Definition: Chara.cs:7709
Card held
Definition: Chara.cs:70
bool IsEyth
Definition: Chara.cs:1099
bool isAlawysVisible
Definition: Chara.cs:405
List< Element > ListAvailabeFeats(bool pet=false, bool showAll=false, bool purchaseFeat=false)
Definition: Chara.cs:10535
bool CanAcceptGift(Chara c, Card t)
Definition: Chara.cs:8780
bool IsLevitating
Definition: Chara.cs:603
WorkSummary GetWorkSummary()
Definition: Chara.cs:9763
float idleTimer
Definition: Chara.cs:122
override void Rotate(bool reverse=false)
Definition: Chara.cs:3790
AIAct ai
Definition: Chara.cs:206
void RemoveGlobal()
Definition: Chara.cs:1572
Chara CreateReplacement()
Definition: Chara.cs:8523
bool TryUse(Thing t)
Definition: Chara.cs:8384
override Sprite GetImageSprite()
Definition: Chara.cs:7499
void ValidateWorks()
Definition: Chara.cs:9841
bool IsFusable(Chara c)
Definition: Chara.cs:1896
void MoveHome(Zone zone, int x=-1, int z=-1)
Definition: Chara.cs:3725
void ChangeMemberType(FactionMemberType type)
Definition: Chara.cs:7504
void TickCooldown()
Definition: Chara.cs:9342
void CureTempElements(int p, bool body, bool mind)
Definition: Chara.cs:11006
bool IsDragon
Definition: Chara.cs:1010
bool TryNeckHunt(Chara TC, int power, bool harvest=false)
Definition: Chara.cs:10288
void UnmakeMinion()
Definition: Chara.cs:2596
Element GetBuffStats(string alias)
Definition: Chara.cs:10059
bool IsWealthy
Definition: Chara.cs:1102
bool isWet
Definition: Chara.cs:144
static NoGoal _NoGoalPC
Definition: Chara.cs:200
void Cuddle(Chara c, bool headpat=false)
Definition: Chara.cs:6629
List< Chara > ListFussableCharas(int radius=2)
Definition: Chara.cs:1921
ConSuspend conSuspend
Definition: Chara.cs:104
bool IsCriticallyWounded(bool includeRide=false)
Definition: Chara.cs:1236
void ModTempElement(int ele, int a, bool naturalDecay=false, bool onlyRenew=false)
Definition: Chara.cs:10914
bool CanRevive()
Definition: Chara.cs:5471
bool isAstralBody
Definition: Chara.cs:156
bool CanPick(Card c)
Definition: Chara.cs:4568
void SetAIIdle()
Definition: Chara.cs:9476
string idFaith
Definition: Chara.cs:235
bool CanInteractTo(Point p)
Definition: Chara.cs:2784
override void SetSortVal(UIList.SortMode m, CurrencyType currency=CurrencyType.Money)
Definition: Chara.cs:7768
void TryPutShared(Thing t, List< Thing > containers=null, bool dropIfFail=true)
Definition: Chara.cs:4740
void CureHost(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:10139
int[] _cints
Definition: Chara.cs:82
int stealthSeen
Definition: Chara.cs:192
bool canSeeInvisible
Definition: Chara.cs:140
int sharedCheckTurn
Definition: Chara.cs:120
void RefreshWorkElements(ElementContainer parent=null)
Definition: Chara.cs:9620
bool MutateRandom(int vec=0, int tries=100, bool ether=false, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:10658
void InstantEat(Thing t=null, bool sound=true)
Definition: Chara.cs:8064
Goal GetGoalFromTimeTable(int hour)
Definition: Chara.cs:9393
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9875
override Sprite GetSprite(int dir=0)
Definition: Chara.cs:7113
bool IsHostile(Chara c)
Definition: Chara.cs:6951
Faction _faction
Definition: Chara.cs:160
Thing FindAmmo(Thing weapon)
Definition: Chara.cs:8316
Faction faction
Definition: Chara.cs:431
override bool isThing
Definition: Chara.cs:702
int Speed
Definition: Chara.cs:1142
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8445
override bool IsPC
Definition: Chara.cs:630
string idFaction
Definition: Chara.cs:247
int combatCount
Definition: Chara.cs:116
GoalListType goalListType
Definition: Chara.cs:283
bool CanAcceptItem(Card t, int num=-1, bool skipImportantCheck=false)
Definition: Chara.cs:8759
override CardRow sourceRenderCard
Definition: Chara.cs:457
void Divorce(Chara c)
Definition: Chara.cs:8623
void _MakeAlly()
Definition: Chara.cs:2542
override int GetArmorSkill()
Definition: Chara.cs:8375
void EnhanceTempElement(int ele, int p, bool onlyRenew=false)
Definition: Chara.cs:10986
static bool consumeTurn
Definition: Chara.cs:184
bool isDrunk
Definition: Chara.cs:126
Chara host
Definition: Chara.cs:33
bool knowFav
Definition: Chara.cs:417
void SetFaith(Religion r)
Definition: Chara.cs:1789
Thing MakeBraineCell()
Definition: Chara.cs:8723
bool IsPlant
Definition: Chara.cs:1022
bool IsValidGiftWeight(Card t, int num=-1)
Definition: Chara.cs:8749
Condition AddCondition(Condition c, bool force=false)
Definition: Chara.cs:9887
SourceJob.Row job
Definition: Chara.cs:470
Point GetFirstStep(Point newPoint, PathManager.MoveType moveType=PathManager.MoveType.Default)
Definition: Chara.cs:2833
Chara GetNearbyCatToSniff()
Definition: Chara.cs:8634
void RemoveAllStances()
Definition: Chara.cs:10276
List< int > _cooldowns
Definition: Chara.cs:58
static List< SourceCategory.Row > _listFavCat
Definition: Chara.cs:198
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:10554
void ResetUpgrade()
Definition: Chara.cs:9156
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1309
AIAct SetNoGoal()
Definition: Chara.cs:9485
bool IsMofuable
Definition: Chara.cs:1158
bool IsMaid
Definition: Chara.cs:1074
override bool IsGlobal
Definition: Chara.cs:628
override bool IsPCParty
Definition: Chara.cs:633
static Point shared
Definition: Chara.cs:11
bool IsAstralBody
Definition: Chara.cs:506
int DestDist
Definition: Chara.cs:1045
override MoveResult TryMove(Point newPoint, bool allowDestroyPath=true)
Definition: Chara.cs:2940
void ShowDialog()
Definition: Chara.cs:7509
override void WriteNote(UINote n, Action< UINote > onWriteNote=null, IInspect.NoteMode mode=IInspect.NoteMode.Default, Recipe recipe=null)
Definition: Chara.cs:7758
override string ToString()
Definition: Chara.cs:1231
Party party
Definition: Chara.cs:43
Chara TryDuplicate(DuplicateCondition con=DuplicateCondition.Default, Point dest=null, bool inheritHostility=false)
Definition: Chara.cs:1962
void TryTakeSharedItems(IEnumerable< Thing > containers, bool msg=true, bool shouldEat=true)
Definition: Chara.cs:7884
bool CanDestroyPath()
Definition: Chara.cs:2672
ElementContainer tempElements
Definition: Chara.cs:36
void TryPutSharedItems(bool msg=true)
Definition: Chara.cs:7874
void SetMainElement(int id, int v=0, bool elemental=false)
Definition: Chara.cs:2309
Stats hygiene
Definition: Chara.cs:1211
int interest
Definition: Chara.cs:321
void ApplyRace(bool remove=false)
Definition: Chara.cs:2464
int corruption
Definition: Chara.cs:381
bool RequestProtection(Chara attacker, Action< Chara > action)
Definition: Chara.cs:8956
void OnAdvanceDay()
Definition: Chara.cs:10807
int GetHappiness()
Definition: Chara.cs:7733
void ModHeight(int a)
Definition: Chara.cs:10441
PathProgress path
Definition: Chara.cs:92
bool isParalyzed
Definition: Chara.cs:134
int EvalueRiding()
Definition: Chara.cs:6528
bool IsInCombat
Definition: Chara.cs:911
bool TryWorkOutside(SourceHobby.Row sourceWork)
Definition: Chara.cs:9793
TraitBed TryAssignBed()
Definition: Chara.cs:7823
void UpdateAngle()
Definition: Chara.cs:3851
override void OnSerializing()
Definition: Chara.cs:1375
List< Condition > conditions
Definition: Chara.cs:215
int MaxGeneSlot
Definition: Chara.cs:1115
bool IsBranchMember()
Definition: Chara.cs:7003
void SetMutation(int idEle, int a=0)
Definition: Chara.cs:10621
void HoldCard(Card t, int num=-1)
Definition: Chara.cs:4770
void PickHeld(bool msg=false)
Definition: Chara.cs:4826
static bool isOnCreate
Definition: Chara.cs:188
bool HasCondition(string alias)
Definition: Chara.cs:10047
SpriteReplacer spriteReplacer
Definition: Chara.cs:158
void Banish(Chara owner)
Definition: Chara.cs:2576
void Kiss(Chara c)
Definition: Chara.cs:6668
static List< Thing > _ListItems
Definition: Chara.cs:194
AIAct SetAI(AIAct g)
Definition: Chara.cs:9490
Chara SetHomeZone(Zone zone)
Definition: Chara.cs:1498
bool IsIdle
Definition: Chara.cs:900
Chara SetFaction(Faction f)
Definition: Chara.cs:1490
void SetMainElement(string id, int v=0, bool elemental=false)
Definition: Chara.cs:2300
void HealAll()
Definition: Chara.cs:1795
override bool IsDisabled
Definition: Chara.cs:591
void Marry(Chara c)
Definition: Chara.cs:8610
int CurrentGeneSlot
Definition: Chara.cs:1130
Thing GetBestRangedWeapon()
Definition: Chara.cs:8331
TraitBed FindBed()
Definition: Chara.cs:7811
bool CanDuplicate(DuplicateCondition con=DuplicateCondition.Default)
Definition: Chara.cs:1926
bool IsPrisoner
Definition: Chara.cs:1085
bool IsNeutralOrAbove()
Definition: Chara.cs:6998
bool IsAdventurer
Definition: Chara.cs:1088
bool _isLevitating
Definition: Chara.cs:136
bool hasMovedThisTurn
Definition: Chara.cs:180
int happiness
Definition: Chara.cs:110
void DiminishTempElements(int a=1)
Definition: Chara.cs:10991
Thing GetRandomRangedWeapon()
Definition: Chara.cs:8346
int uidEditor
Definition: Chara.cs:357
Stats hunger
Definition: Chara.cs:1201
int GetCurrentDir()
Definition: Chara.cs:3890
override string GetName(NameStyle style, int num=-1)
Definition: Chara.cs:1420
override bool IsMinion
Definition: Chara.cs:645
int GetHireCost()
Definition: Chara.cs:7728
Chara SetGlobal(Zone _home, int x, int z)
Definition: Chara.cs:1544
void EnhanceTempElements(int p, bool body, bool mind, bool onlyRenew=false)
Definition: Chara.cs:10977
override string GetHoverText()
Definition: Chara.cs:7222
override int WeightLimit
Definition: Chara.cs:728
override void OnDeserialized()
Definition: Chara.cs:1390
override void SetSource()
Definition: Chara.cs:2288
int contribution
Definition: Chara.cs:18
bool TryHoldCard(Card t, int num=-1, bool pickHeld=false)
Definition: Chara.cs:4748
override bool isSynced
Definition: Chara.cs:709
static List< Hobby > listHobby
Definition: Chara.cs:13
Point orgPos
Definition: Chara.cs:21
int CalcCastingChance(Element e, int num=1)
Definition: Chara.cs:6537
bool ShouldEquip(Thing t, bool useFav=false)
Definition: Chara.cs:8114
bool CanMoveTo(Point p, bool allowDestroyPath=true)
Definition: Chara.cs:2685
Emo2 emoIcon
Definition: Chara.cs:108
bool IsHuman
Definition: Chara.cs:926
WorkSummary _workSummary
Definition: Chara.cs:55
bool HasMinion(string id)
Definition: Chara.cs:2629
override bool HasHost
Definition: Chara.cs:706
bool MoveRandom()
Definition: Chara.cs:2838
bool IsAnimal
Definition: Chara.cs:914
void DestroyPath(Point pos)
Definition: Chara.cs:3430
int daysStarved
Definition: Chara.cs:333
int CountDebuff()
Definition: Chara.cs:10076
override CardRenderer _CreateRenderer()
Definition: Chara.cs:7063
void PickOrDrop(Point p, string idThing, int idMat=-1, int num=1, bool msg=true)
Definition: Chara.cs:4586
void TryPutSharedItems(IEnumerable< Thing > containers, bool msg=true)
Definition: Chara.cs:7841
override bool IsPCFaction
Definition: Chara.cs:689
override bool IsPCPartyMinion
Definition: Chara.cs:657
bool TryNullifyCurse()
Definition: Chara.cs:10781
override int SelfWeight
Definition: Chara.cs:730
void CalculateMaxStamina()
Definition: Chara.cs:2232
int MaxSummon
Definition: Chara.cs:732
Chara ScaleByPrincipal()
Definition: Chara.cs:1773
Thing TryGetThrowable()
Definition: Chara.cs:8270
void MoveZone(Zone z, ZoneTransition transition)
Definition: Chara.cs:3590
void TryUpgrade(bool msg=true)
Definition: Chara.cs:9161
int calmCheckTurn
Definition: Chara.cs:118
void MakeMinion(Chara _master, MinionType type=MinionType.Default)
Definition: Chara.cs:2585
override void LookAt(Point p)
Definition: Chara.cs:3809
void OnBanish()
Definition: Chara.cs:1512
override bool flipX
Definition: Chara.cs:553
string NameBraced
Definition: Chara.cs:520
Condition AddCondition(string id, int p, int p2, bool force=false)
Definition: Chara.cs:9880
bool CanSee(Card c)
Definition: Chara.cs:1277
bool HasAccess(Card c)
Definition: Chara.cs:1343
Goal GetGoalWork()
Definition: Chara.cs:9425
override int DV
Definition: Chara.cs:747
ConSleep conSleep
Definition: Chara.cs:102
override bool IsPCFactionMinion
Definition: Chara.cs:673
void Vomit()
Definition: Chara.cs:5630
void SetCooldown(int idEle, int turns=0)
Definition: Chara.cs:9289
void AddWork(int id)
Definition: Chara.cs:9702
bool IsFriendOrAbove()
Definition: Chara.cs:7042
void Slap(Chara c, bool slapToDeath=false)
Definition: Chara.cs:6695
override MoveResult _Move(Point newPoint, MoveType type=MoveType.Walk)
Definition: Chara.cs:2964
bool CanEat(Thing t, bool shouldEat=false)
Definition: Chara.cs:8089
float actTime
Definition: Chara.cs:182
Tactics _tactics
Definition: Chara.cs:168
bool ShouldThrowAway(Thing t, ClearInventoryType type)
Definition: Chara.cs:9028
int GeneCostMTP
Definition: Chara.cs:1118
void SetAIAggro()
Definition: Chara.cs:9480
ElementContainer _baseWorkElements
Definition: Chara.cs:208
override void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Chara.cs:5666
Chara Duplicate()
Definition: Chara.cs:1984
void MakePartyMemeber()
Definition: Chara.cs:2516
void SetAIImmediate(AIAct g)
Definition: Chara.cs:9522
void PerformWork(WorkSession session, bool isHobby=false, bool IsRealTime=false)
Definition: Chara.cs:9805
void PickOrDrop(Point p, Thing t, bool msg=true)
Definition: Chara.cs:4594
static GoalHobby _goalHobby
Definition: Chara.cs:212
void ClearTempElements()
Definition: Chara.cs:11036
override int MaxHP
Definition: Chara.cs:726
Zone currentZone
Definition: Chara.cs:259
bool IsFairy
Definition: Chara.cs:986
bool HasAccess(Point p)
Definition: Chara.cs:1348
override bool isChara
Definition: Chara.cs:704
string Aka
Definition: Chara.cs:220
override bool IsDeadOrSleeping
Definition: Chara.cs:579
Stats bladder
Definition: Chara.cs:1209
bool CanReplace(Chara c)
Definition: Chara.cs:3541
List< Hobby > ListHobbies(bool useMemberType=true)
Definition: Chara.cs:9581
void TryClearInventory()
Definition: Chara.cs:9099
Thing ranged
Definition: Chara.cs:98
Stats SAN
Definition: Chara.cs:1217
void MakeAlly(bool msg=true)
Definition: Chara.cs:2522
void RemoveLastBodyPart(bool msg=false)
Definition: Chara.cs:2427
ElementContainer baseWorkElements
Definition: Chara.cs:1170
void TickWork(VirtualDate date)
Definition: Chara.cs:9772
Goal GetGoalHobby()
Definition: Chara.cs:9438
int _maxStamina
Definition: Chara.cs:369
bool isWeakToSunlight
Definition: Chara.cs:154
void Stumble(int mtp=100)
Definition: Chara.cs:2052
void ClearInventory(ClearInventoryType type)
Definition: Chara.cs:9133
SourceChara.Row source
Definition: Chara.cs:162
new Point lastPos
Definition: Chara.cs:90
void GainAbility(int ele, int mtp=100, Thing origin=null)
Definition: Chara.cs:10757
bool isCreated
Definition: Chara.cs:138
Stats mana
Definition: Chara.cs:1213
void MoveByForce(Point newPoint, Card c=null, bool checkWall=false)
Definition: Chara.cs:2870
bool FindNewEnemy()
Definition: Chara.cs:6854
FactionMemberType memberType
Definition: Chara.cs:46
string TalkTopic(string topic="calm")
Definition: Chara.cs:7432
int _idTimeTable
Definition: Chara.cs:345
void TryDropBossLoot()
Definition: Chara.cs:5995
override int PV
Definition: Chara.cs:776
string GetIdPortraitCat()
Definition: Chara.cs:8682
SourceRace.Row _race
Definition: Chara.cs:164
Stats stamina
Definition: Chara.cs:1205
bool CanGainConResist
Definition: Chara.cs:1220
string NameTitled
Definition: Chara.cs:522
bool HasHigherGround(Card c)
Definition: Chara.cs:1249
void TryRestock(bool onCreate)
Definition: Chara.cs:4985
void RestockInventory(bool onCreate)
Definition: Chara.cs:5346
List< List< string > > _historyFood
Definition: Chara.cs:64
bool MoveNeighborDefinitely()
Definition: Chara.cs:2852
bool CanSleep()
Definition: Chara.cs:1362
bool UseAbility(int idAct, Card tc=null, Point pos=null, bool pt=false)
Definition: Chara.cs:6161
Stats burden
Definition: Chara.cs:1203
void AddHobby(int id)
Definition: Chara.cs:9690
bool visibleWithTelepathy
Definition: Chara.cs:152
void ChangeJob(string idNew)
Definition: Chara.cs:2387
GlobalData global
Definition: Chara.cs:76
SourceThing.Row GetFavFood()
Definition: Chara.cs:8544
override bool IsMoving
Definition: Chara.cs:626
void SetTempHand(int right=0, int left=0)
Definition: Chara.cs:7147
int[] rawSlots
Definition: Chara.cs:73
void GoHostile(Card _tg)
Definition: Chara.cs:6737
void ApplyJob(bool remove=false)
Definition: Chara.cs:2378
bool IsGod
Definition: Chara.cs:998
bool IsHomeMember()
Definition: Chara.cs:7012
Chara parasite
Definition: Chara.cs:30
void AddRandomBodyPart(bool msg=false)
Definition: Chara.cs:2416
string GetActionText()
Definition: Chara.cs:7748
void SyncRide(Chara c)
Definition: Chara.cs:4238
Chara master
Definition: Chara.cs:88
List< Hobby > ListWorks(bool useMemberType=true)
Definition: Chara.cs:9554
Card DropHeld(Point dropPos=null)
Definition: Chara.cs:4903
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:5497
void TryReservePickupTutorial(Thing t)
Definition: Chara.cs:4700
Chara ride
Definition: Chara.cs:27
LayerDrama ShowDialog(string book, string step="main", string tag="")
Definition: Chara.cs:7704
Zone homeZone
Definition: Chara.cs:271
void RefreshFaithElement()
Definition: Chara.cs:10871
ElementContainer faithElements
Definition: Chara.cs:38
override void ChangeRarity(Rarity r)
Definition: Chara.cs:1477
void GiveLovePotion(Chara c, Thing t)
Definition: Chara.cs:8946
bool IsUndead
Definition: Chara.cs:938
void AddCooldown(int idEle, int turns=0)
Definition: Chara.cs:9271
bool IsGuest()
Definition: Chara.cs:7037
int GetTotalFeat()
Definition: Chara.cs:8656
Hobby GetWork(string id)
Definition: Chara.cs:9601
GoalList goalList
Definition: Chara.cs:204
bool IsHorror
Definition: Chara.cs:962
SourceJob.Row _job
Definition: Chara.cs:166
bool CanOpenDoor
Definition: Chara.cs:842
void SetEQQuality()
Definition: Chara.cs:5385
void RerollHobby(bool extraSlotChance=true)
Definition: Chara.cs:9714
Thing MakeGene(DNA.Type? type=null)
Definition: Chara.cs:8718
void RefreshSpeed(Element.BonusInfo info=null)
Definition: Chara.cs:2078
static List< SourceRace.Row > ListAdvRace
Definition: Chara.cs:170
bool IsLocalChara
Definition: Chara.cs:888
bool CanBeTempAlly(Chara c)
Definition: Chara.cs:2563
bool CanBloom()
Definition: Chara.cs:9254
int GetCooldown(int idEle)
Definition: Chara.cs:9327
override string AliasMaterialOnCreate
Definition: Chara.cs:564
void ModWeight(int a, bool ignoreLimit=false)
Definition: Chara.cs:10463
bool ignoreSPAbsorb
Definition: Chara.cs:148
void AddFoodHistory(Thing food)
Definition: Chara.cs:10822
override CardRow sourceCard
Definition: Chara.cs:454
BaseArea GetRoomWork()
Definition: Chara.cs:9532
bool CanInteractTo(Card c)
Definition: Chara.cs:2779
Thing nextUse
Definition: Chara.cs:100
Affinity affinity
Definition: Chara.cs:318
string GetTopicText(string topic="calm")
Definition: Chara.cs:7398
static NoGoal _NoGoalRepeat
Definition: Chara.cs:202
void ModCorruption(int a)
Definition: Chara.cs:10492
void RestockEquip(bool onCreate)
Definition: Chara.cs:4995
override void SetDir(int d)
Definition: Chara.cs:3783
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2878
bool isBerserk
Definition: Chara.cs:124
void BanishAllMinions()
Definition: Chara.cs:2613
Religion faith
Definition: Chara.cs:443
List< int > _hobbies
Definition: Chara.cs:49
bool FindNearestNewEnemy()
Definition: Chara.cs:6931
string GetIdPortrait()
Definition: Chara.cs:8696
bool HasNoGoal
Definition: Chara.cs:1047
bool IsMarried
Definition: Chara.cs:615
Element GetFavWeaponSkill()
Definition: Chara.cs:4971
void DropThing(Thing t, int num=-1)
Definition: Chara.cs:4923
Chara enemy
Definition: Chara.cs:86
void GiveGift(Chara c, Thing t)
Definition: Chara.cs:8809
void EQ_Item(string s, int num=1)
Definition: Chara.cs:5454
BitArray32 _cbits1
Definition: Chara.cs:84
string GetTextHappiness()
Definition: Chara.cs:7743
CharaAbility ability
Definition: Chara.cs:428
bool IsInActiveZone
Definition: Chara.cs:885
override void Tick()
Definition: Chara.cs:4251
Quest quest
Definition: Chara.cs:24
Chara FindMaster()
Definition: Chara.cs:2647
override bool IsMultisize
Definition: Chara.cs:724
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6712
void SyncRide()
Definition: Chara.cs:4222
void CallHelp(Chara tg, bool fanatic=false)
Definition: Chara.cs:6843
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6761
bool isBlind
Definition: Chara.cs:132
bool CanSeeSimple(Point p)
Definition: Chara.cs:1260
bool dirtySpeed
Definition: Chara.cs:174
Thing EQ_ID(string s, int mat=-1, Rarity r=Rarity.Random)
Definition: Chara.cs:5418
void ClearBed(Map map=null)
Definition: Chara.cs:7796
bool IsMachine
Definition: Chara.cs:950
override void SetRenderParam(RenderParam p)
Definition: Chara.cs:7172
void AddResistCon(Condition con)
Definition: Chara.cs:10313
void MoveZone(Zone z, ZoneTransition.EnterState state=ZoneTransition.EnterState.Auto)
Definition: Chara.cs:3582
bool UseAbility(Act a, Card tc=null, Point pos=null, bool pt=false)
Definition: Chara.cs:6171
bool TryEquip(Thing t, bool useFav=false)
Definition: Chara.cs:8226
Room FindRoom()
Definition: Chara.cs:8440
override SubPassData GetSubPassData()
Definition: Chara.cs:7156
bool CanSeeLos(Point p, int dist=-1)
Definition: Chara.cs:1318
int CountNumEaten(Thing food)
Definition: Chara.cs:10842
Point GetDestination()
Definition: Chara.cs:7723
int turnLastSeen
Definition: Chara.cs:112
static bool preventRegen
Definition: Chara.cs:186
void ResistCon(Condition con)
Definition: Chara.cs:10333
void SetSummon(int duration)
Definition: Chara.cs:2641
string _alias
Definition: Chara.cs:223
FactionBranch homeBranch
Definition: Chara.cs:1113
Element GetFavArmorSkill()
Definition: Chara.cs:4976
int GetPietyValue()
Definition: Chara.cs:10862
void ChooseNewGoal()
Definition: Chara.cs:9361
void DamageTempElements(int p, bool body, bool mind, bool onlyRenew=false)
Definition: Chara.cs:10960
bool IsEnemyOnPath(Point p, bool cancelAI=true)
Definition: Chara.cs:2756
void FallFromZone()
Definition: Chara.cs:3770
void Drink(Card t)
Definition: Chara.cs:5461
Hostility hostility
Definition: Chara.cs:295
void InitStats(bool onDeserialize=false)
Definition: Chara.cs:9847
bool isFainted
Definition: Chara.cs:130
void MoveHome(string id, int x=-1, int z=-1)
Definition: Chara.cs:3720
Tactics tactics
Definition: Chara.cs:857
bool CanWitness
Definition: Chara.cs:1050
Card SplitHeld(int a)
Definition: Chara.cs:4886
void TryDropCarryOnly()
Definition: Chara.cs:4891
bool IsHostile()
Definition: Chara.cs:6946
bool IsInHomeZone()
Definition: Chara.cs:7017
bool isDead
Definition: Chara.cs:393
bool TryIdentify(Thing t, int count=1, bool show=true)
Definition: Chara.cs:8501
Thing TryPoisonPotion(Thing t)
Definition: Chara.cs:4656
long _Speed
Definition: Chara.cs:176
void TryTakeSharedItems(bool msg=true)
Definition: Chara.cs:7879
override void LookAt(Card c)
Definition: Chara.cs:3804
bool isConfused
Definition: Chara.cs:128
static List< SourceThing.Row > _listFavFood
Definition: Chara.cs:196
ConBaseTransmuteMimic mimicry
Definition: Chara.cs:106
void SaiyanRevive()
Definition: Chara.cs:5569
bool TryEquipRanged()
Definition: Chara.cs:8351
void SetFaith(string id)
Definition: Chara.cs:1784
PCCData pccData
Definition: Chara.cs:67
void ApplyDeathPenalty()
Definition: Chara.cs:5603
void Cure(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:10152
static string[] IDTimeTable
Definition: Chara.cs:15
TimeTable.Span CurrentSpan
Definition: Chara.cs:859
Chara SetHostility(Hostility h)
Definition: Chara.cs:1505
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4606
bool CanLift(Card c)
Definition: Chara.cs:4558
List< int > _listAbility
Definition: Chara.cs:61
void TrySetEnemy(Chara c)
Definition: Chara.cs:6729
string idTimeTable
Definition: Chara.cs:472
override void OnCreate(int genLv)
Definition: Chara.cs:1597
void TryAbsorbRod(Thing t)
Definition: Chara.cs:4670
bool CanAutoPick(Card c)
Definition: Chara.cs:4563
void Sniff(Chara c)
Definition: Chara.cs:8646
List< int > _works
Definition: Chara.cs:52
string GetTextWork(bool simple=false)
Definition: Chara.cs:9680
override bool IsPCC
Definition: Chara.cs:700
bool TryFuse(float chance=1f)
Definition: Chara.cs:1838
void TryPush(Point point)
Definition: Chara.cs:3474
string GetTextHobby(bool simple=false)
Definition: Chara.cs:9670
Dictionary< int, int > resistCon
Definition: Chara.cs:218
void OnSleep(Thing bed=null, int days=1)
Definition: Chara.cs:10371
bool hasTelepathy
Definition: Chara.cs:142
CharaAbility _ability
Definition: Chara.cs:96
Chara SetGlobal()
Definition: Chara.cs:1559
bool CanInsult()
Definition: Chara.cs:8670
void EQ_CAT(string s)
Definition: Chara.cs:5438
bool bossText
Definition: Chara.cs:146
override string GetHoverText2()
Definition: Chara.cs:7298
bool IsEscorted()
Definition: Chara.cs:2656
int ParseBodySlot(string s)
Definition: Chara.cs:2399
bool CanEquipRanged(Thing t)
Definition: Chara.cs:8265
void Sleep(Thing bed=null, Thing pillow=null, bool pickup=false, ItemPosition posBed=null, ItemPosition posPillow=null)
Definition: Chara.cs:10357
void OnGiveErohon(Thing t)
Definition: Chara.cs:8935
override int PrefIndex
Definition: Chara.cs:537
AttackStyle GetFavAttackStyle()
Definition: Chara.cs:4951
bool HasCooldown(int idEle)
Definition: Chara.cs:9322
static GoalWork _goalWork
Definition: Chara.cs:210
int idleActTimer
Definition: Chara.cs:114
bool IsFish
Definition: Chara.cs:974
bool IsCat
Definition: Chara.cs:1034
void OnSleep(int power, int days=1, bool isSunLit=false)
Definition: Chara.cs:10391
void DoAI(int wait, Action onPerform)
Definition: Chara.cs:6617
ElementContainer workElements
Definition: Chara.cs:40
bool WillConsumeTurn()
Definition: Chara.cs:3928
bool IsNeutral()
Definition: Chara.cs:6993
static List< SourceJob.Row > ListAdvJob
Definition: Chara.cs:172
void MoveZone(string alias)
Definition: Chara.cs:3577
void CalcBurden()
Definition: Chara.cs:2037
void SetPCCState(PCCState state)
Definition: Chara.cs:7105
SourceRace.Row race
Definition: Chara.cs:468
Element GetBuffStats(int ele)
Definition: Chara.cs:10064
void MakeGrave(string lastword)
Definition: Chara.cs:5583
override void OnBeforeCreate()
Definition: Chara.cs:1581
bool DroppedCard(string id)
Definition: CodexManager.cs:46
void MarkCardDrop(string id)
Definition: CodexManager.cs:41
Color colorHostile
Color colorBlood
Color colorDebuff
Color colorFriend
UD_String_MatData matColors
Gradient gradientLVComparison
virtual string GetHoverText2()
virtual string GetName(NameStyle style, int num=-1)
virtual string GetHoverText()
virtual bool IsKilled
Definition: Condition.cs:8
void Kill(bool silent=false)
Definition: Condition.cs:108
override void Tick()
Definition: Condition.cs:87
static Condition Create(string alias, int power=100, Action< Condition > onCreate=null)
Definition: Condition.cs:47
bool allyKeepDistance
Definition: ConfigTactics.cs:6
static void Collect(Thing t)
bool ignoreBackerDestoryFlag
Definition: CoreConfig.cs:578
new GameConfig game
Definition: CoreConfig.cs:629
BackerContentConfig backer
Definition: CoreConfig.cs:633
bool ignoreWeight
Definition: CoreDebug.cs:203
bool godMode
Definition: CoreDebug.cs:189
bool showExtra
Definition: CoreDebug.cs:184
bool ignoreEncounter
Definition: CoreDebug.cs:217
bool enable
Definition: CoreDebug.cs:302
bool ignoreAutoSave
Definition: CoreDebug.cs:142
static string DramaData
Definition: CorePath.cs:174
SourcePref snowputit2
Definition: CoreRef.cs:329
SourcePref sonwputit1
Definition: CoreRef.cs:327
SourcePref replacer1
Definition: CoreRef.cs:333
PrefData prefs
Definition: CoreRef.cs:420
CoreRef refs
Definition: Core.cs:51
bool IsGameStarted
Definition: Core.cs:87
PCCManager pccs
Definition: Core.cs:41
CoreConfig config
Definition: Core.cs:70
static Thing MakeLoveLunch(Chara c)
Definition: CraftUtil.cs:221
static string GetBloodText(Chara c)
Definition: CraftUtil.cs:118
Definition: DNA.cs:9
Type
Definition: DNA.cs:11
static Thing GenerateGene(Chara c, Type? type=null)
Definition: DNA.cs:106
int hour
Definition: Date.cs:74
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
bool IsExpired(int time)
Definition: Date.cs:338
bool IsNight
Definition: Date.cs:112
Definition: Dialog.cs:7
static bool warned
Definition: Dialog.cs:50
static void TryWarnMana(Action action)
Definition: Dialog.cs:399
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static Scene scene
Definition: EClass.cs:31
static Faction Home
Definition: EClass.cs:27
static ColorProfile Colors
Definition: EClass.cs:39
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static bool AdvMode
Definition: EClass.cs:11
static float rndf(float a)
Definition: EClass.cs:102
static FactionBranch Branch
Definition: EClass.cs:23
static BaseGameScreen screen
Definition: EClass.cs:33
static int rndHalf(int a)
Definition: EClass.cs:97
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static int sqrt(int a)
Definition: EClass.cs:88
static CoreDebug debug
Definition: EClass.cs:49
static SoundManager Sound
Definition: EClass.cs:47
static UI ui
Definition: EClass.cs:17
static GameSetting setting
Definition: EClass.cs:35
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:667
Definition: Effect.cs:7
Effect _Play(Point from, Vector3 fromV, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:117
static Effect Get(Effect original)
Definition: Effect.cs:80
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
void ModExp(int ele, float a, bool chain=false)
Dictionary< int, Element > dict
void SetParent(Card c)
int Value(int ele)
int ValueWithoutLink(int ele)
Element ModBase(int ele, int v)
void ApplyElementMap(int uid, SourceValueType type, Dictionary< int, int > map, int lv, bool invert=false, bool applyFeat=false)
void SetTo(int id, int v)
Element SetBase(string alias, int v, int potential=0)
void Remove(int id)
Element GetElement(string alias)
int GetDNABonus(Chara c)
Definition: ELEMENT.cs:531
int ValueWithoutLink
Definition: ELEMENT.cs:303
static int[] List_Body
Definition: ELEMENT.cs:253
int id
Definition: ELEMENT.cs:259
int vBase
Definition: ELEMENT.cs:261
SourceElement.Row source
Definition: ELEMENT.cs:282
int vPotential
Definition: ELEMENT.cs:265
static SourceElement.Row Get(int id)
Definition: ELEMENT.cs:410
bool HasTag(string tag)
Definition: ELEMENT.cs:482
virtual int GetPower(Card c)
Definition: ELEMENT.cs:1134
int Value
Definition: ELEMENT.cs:301
virtual string Name
Definition: ELEMENT.cs:313
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1163
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:1092
static List< SourceElement.Row > ListElements
Definition: ELEMENT.cs:277
virtual bool PotentialAsStock
Definition: ELEMENT.cs:345
int vSource
Definition: ELEMENT.cs:271
static Element Void
Definition: ELEMENT.cs:247
static int[] List_Mind
Definition: ELEMENT.cs:255
virtual int CostLearn
Definition: ELEMENT.cs:323
static int[] List_MainAttributesMajor
Definition: ELEMENT.cs:251
Act act
Definition: ELEMENT.cs:403
bool IsMainAttribute
Definition: ELEMENT.cs:392
Zone zone
Definition: EloMap.cs:11
bool shore
Definition: EloMap.cs:50
Cell GetCell(Point pos)
Definition: EloMap.cs:272
TileInfo GetTileInfo(int gx, int gy)
Definition: EloMap.cs:286
void Add(Expedition ex)
static Expedition Create(Chara c, ExpeditionType type)
Definition: Expedition.cs:119
int hours
Definition: Expedition.cs:7
Definition: FLOOR.cs:2
static SourceFloor.Row sourceSnow
Definition: FLOOR.cs:31
static SourceFloor.Row sourceIce
Definition: FLOOR.cs:35
static bool IsTatami(int id)
Definition: FLOOR.cs:39
static SourceFloor.Row sourceWood
Definition: FLOOR.cs:37
ExpeditionManager expeditions
int Evalue(int ele)
void RemoveMemeber(Chara c)
PolicyManager policies
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
bool HasItemProtection
void AddMemeber(Chara c)
Dictionary< string, Faction > dictAll
Hostility GetHostility()
Definition: FACTION.cs:255
Definition: FEAT.cs:345
override string FullName
Definition: FEAT.cs:355
virtual List< string > Apply(int a, ElementContainer owner, bool hint=false)
Definition: FEAT.cs:425
override bool IsPurchaseFeatReqMet(ElementContainer owner, int lv=-1)
Definition: FEAT.cs:399
static void ProcDrink(Chara c, Thing food)
Definition: FoodEffect.cs:368
static void Proc(Chara c, Thing food, bool consume=true)
Definition: FoodEffect.cs:16
Dictionary< int, byte > lastPoints
Definition: Fov.cs:36
void AdvanceMin(int a)
Definition: GameDate.cs:24
static string Parse(string text, bool thirdPerson, string val1, string val2=null, string val3=null, string val4=null)
Definition: GameLang.cs:177
bool disableVoidBlessing
bool disableDeathPenaltyProtection
RenderData renderTempEQ
Definition: GameScreen.cs:7
float defaultActPace
Definition: GameSetting.cs:374
PassSetting pass
Definition: GameSetting.cs:350
RenderSetting render
Definition: GameSetting.cs:348
UD_String_ElementRef elements
Definition: GameSetting.cs:362
bool autoCollectCard
Definition: Game.cs:52
ConfigPreference preference
Definition: Game.cs:97
ConfigTactics tactics
Definition: Game.cs:91
ConfigAutoCombat autoCombat
Definition: Game.cs:94
ReligionManager religions
Definition: Game.cs:159
GamePrincipal principal
Definition: Game.cs:225
bool Save(bool isAutoSave=false, bool silent=false)
Definition: Game.cs:1058
SpatialManager spatials
Definition: Game.cs:153
PCCUniformManager uniforms
Definition: Game.cs:195
CardManager cards
Definition: Game.cs:156
Zone activeZone
Definition: Game.cs:252
bool IsSurvival
Definition: Game.cs:276
new World world
Definition: Game.cs:177
Config config
Definition: Game.cs:219
QuestManager quests
Definition: Game.cs:183
int seed
Definition: Game.cs:201
FactionManager factions
Definition: Game.cs:162
GlobalGoal goal
Definition: GlobalData.cs:9
void SetOwner(Chara c)
Definition: GlobalGoal.cs:10
int index
Definition: GoalList.cs:5
void Refresh(Chara owner, GoalListType type)
Definition: GoalList.cs:9
Goal Next()
Definition: GoalList.cs:39
void ValidateHobby(Chara c)
Definition: GoalWork.cs:21
bool FindWork(Chara c, bool setAI=true)
Definition: GoalWork.cs:55
Definition: Goal.cs:4
bool ShowBounty(Chara c)
Definition: GuildFighter.cs:39
bool HasBounty(Chara c)
Definition: GuildFighter.cs:44
Definition: Guild.cs:2
static GuildFighter Fighter
Definition: Guild.cs:56
Definition: Hobby.cs:5
SourceHobby.Row source
Definition: Hobby.cs:8
int GetEfficiency(Chara c)
Definition: Hobby.cs:31
AIWork GetAI(Chara c)
Definition: Hobby.cs:12
virtual Thing Thing
Definition: HotItem.cs:38
static bool Has(string id)
Definition: LangGame.cs:99
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
static string _currency(object a, string IDCurrency)
Definition: Lang.cs:161
static void SetDirty(Element a)
static LayerDrama Activate(string book, string idSheet, string idStep, Chara target=null, Card ref1=null, string tag="")
Definition: LayerDrama.cs:66
static string forceJump
Definition: LayerDrama.cs:18
static LayerDrama ActivateMain(string idSheet, string idStep=null, Chara target=null, Card ref1=null, string tag="")
Definition: LayerDrama.cs:61
static void SetDirty(Thing t)
Definition: Los.cs:5
static bool IsVisible(Point p1, Point p2, Action< Point, bool > _onVisit=null)
Definition: Los.cs:167
static SourceMaterial.Row sourceOak
Definition: MATERIAL.cs:47
static SourceMaterial.Row sourceSnow
Definition: MATERIAL.cs:41
static SourceMaterial.Row sourceIce
Definition: MATERIAL.cs:43
Point GetCenterPos()
Definition: MapBounds.cs:52
bool Contains(int dx, int dz)
Definition: MapBounds.cs:38
Definition: Map.cs:13
bool IsIndoor
Definition: Map.cs:136
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2778
Chara FindChara(string id)
Definition: Map.cs:2754
void MoveCard(Point p, Card t)
Definition: Map.cs:946
void SetLiquid(int x, int z, CellEffect effect=null)
Definition: Map.cs:1617
void SetFoormark(Point pos, int id, int angle, int offset=0)
Definition: Map.cs:2200
List< Chara > deadCharas
Definition: Map.cs:49
PropsManager props
Definition: Map.cs:94
RoomManager rooms
Definition: Map.cs:34
Cell[,] cells
Definition: Map.cs:88
void SetEffect(int x, int z, CellEffect effect=null)
Definition: Map.cs:1648
List< Chara > charas
Definition: Map.cs:84
MapBounds bounds
Definition: Map.cs:55
Definition: MathEx.cs:2
static int ClampToInt(long a)
Definition: MathEx.cs:25
Color Negative
Definition: MsgColors.cs:15
Color Thinking
Definition: MsgColors.cs:17
Color MutateBad
Definition: MsgColors.cs:21
Color Talk
Definition: MsgColors.cs:7
Color Ono
Definition: MsgColors.cs:13
Color Ding
Definition: MsgColors.cs:11
Color MutateGood
Definition: MsgColors.cs:19
Definition: Msg.cs:5
static MsgColors colors
Definition: Msg.cs:20
static ThirstPersonInfo thirdPerson1
Definition: Msg.cs:6
static string SayNothingHappen()
Definition: Msg.cs:96
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: NoGoal.cs:4
int emitFoot
Definition: PCOrbit.cs:9
int emitSmoke
Definition: PCOrbit.cs:11
Vector3 smokePos
Definition: PCOrbit.cs:15
Vector3 footPos
Definition: PCOrbit.cs:13
Definition: Party.cs:7
bool HasElement(int ele, bool excludePC=false)
Definition: Party.cs:212
void RemoveMember(Chara c)
Definition: Party.cs:116
Chara leader
Definition: Party.cs:31
List< Chara > members
Definition: Party.cs:19
void AddMemeber(Chara c, bool showMsg=false)
Definition: Party.cs:71
void RequestPathImmediate(PathProgress progress)
Definition: PathManager.cs:41
Point GetFirstStep(Point origin, Point _dest, IPathfindWalker walker, int maxDist=20, MoveType moveType=MoveType.Default)
Definition: PathManager.cs:67
static PathManager Instance
Definition: PathManager.cs:16
List< PathFinderNode > nodes
Definition: PathProgress.cs:16
bool KilledBossInVoid
Definition: Player.cs:448
bool gotEtherDisease
Definition: Player.cs:496
bool loytelEscaped
Definition: Player.cs:508
int storyFiama
Definition: Player.cs:652
bool little_saved
Definition: Player.cs:472
bool fiamaStoryBookGiven
Definition: Player.cs:328
bool fiamaFirstDream
Definition: Player.cs:340
bool little_killed
Definition: Player.cs:484
bool isShoesOff
Definition: Player.cs:376
int deepest
Definition: Player.cs:111
long nefiaBeaten
Definition: Player.cs:153
int married
Definition: Player.cs:129
int turns
Definition: Player.cs:84
int deepestVoid
Definition: Player.cs:114
int allyDeath
Definition: Player.cs:108
int divorced
Definition: Player.cs:132
int days
Definition: Player.cs:75
int distanceTravel
Definition: Player.cs:960
bool IsCriminal
Definition: Player.cs:1412
Flags flags
Definition: Player.cs:1164
bool TooHeavyToMove()
Definition: Player.cs:2679
CodexManager codex
Definition: Player.cs:1185
bool preventDeathPenalty
Definition: Player.cs:1240
bool deathZoneMove
Definition: Player.cs:1242
void ModFame(int a)
Definition: Player.cs:2192
void ModKarma(int a)
Definition: Player.cs:2636
Stats stats
Definition: Player.cs:1086
int staminaRecovery
Definition: Player.cs:1038
bool haltMove
Definition: Player.cs:1244
bool EnableDreamStory
Definition: Player.cs:1343
bool invlunerable
Definition: Player.cs:1246
float baseActTime
Definition: Player.cs:1272
void EndTurn(bool consume=true)
Definition: Player.cs:2179
void EnterLocalZone(bool encounter=false, Chara mob=null)
Definition: Player.cs:2044
List< Chara > listCarryoverMap
Definition: Player.cs:1296
int little_dead
Definition: Player.cs:993
HashSet< int > doneBackers
Definition: Player.cs:1143
void RecoverStamina(int a)
Definition: Player.cs:1597
Window.SaveData dataPick
Definition: Player.cs:1104
HotItem currentHotItem
Definition: Player.cs:1170
int safeTravel
Definition: Player.cs:987
Thing DropReward(Thing t, bool silent=false)
Definition: Player.cs:2668
ReturnInfo returnInfo
Definition: Player.cs:933
bool regionMoveWarned
Definition: Player.cs:1230
Chara chara
Definition: Player.cs:1278
void UpdateNyan()
Definition: Player.cs:2508
bool TryAbortAutoCombat(bool immediate=true)
Definition: Player.cs:2530
bool simulatingZone
Definition: Player.cs:1252
int lastEmptyAlly
Definition: Player.cs:1266
bool altHeldPos
Definition: Player.cs:1226
QueueManager queues
Definition: Player.cs:1284
string deathMsg
Definition: Player.cs:1258
Definition: Point.cs:9
int eloY
Definition: Point.cs:81
SourceMaterial.Row matFloor
Definition: Point.cs:57
int index
Definition: Point.cs:49
SourceBlock.Row sourceBlock
Definition: Point.cs:63
void ForeachMultiSize(int w, int h, Action< Point, bool > action)
Definition: Point.cs:1391
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:934
ref Vector3 Position(int height)
Definition: Point.cs:553
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1057
Point Copy()
Definition: Point.cs:491
override string ToString()
Definition: Point.cs:524
Point Set(int _x, int _z)
Definition: Point.cs:503
void ForeachNeighbor(Action< Point > action, bool diagonal=true)
Definition: Point.cs:1403
CellDetail detail
Definition: Point.cs:71
bool IsBlocked
Definition: Point.cs:363
List< Thing > Things
Definition: Point.cs:338
int x
Definition: Point.cs:36
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:624
int z
Definition: Point.cs:39
List< Chara > Charas
Definition: Point.cs:340
SoundSource PlaySound(string id, bool synced=true, float v=1f, bool spatial=true)
Definition: Point.cs:1259
int eloX
Definition: Point.cs:79
Point GetPointTowards(Point dest)
Definition: Point.cs:806
List< Chara > ListCharasInRadius(Chara cc, int dist, Func< Chara, bool > func, bool onlyVisible=true)
Definition: Point.cs:1226
bool HasThing
Definition: Point.cs:251
bool Equals(int _x, int _z)
Definition: Point.cs:966
List< Chara > ListCharas()
Definition: Point.cs:1177
SourceFloor.Row sourceFloor
Definition: Point.cs:65
bool IsSunLit
Definition: Point.cs:182
void SetBlock(int idMat=0, int idBlock=0)
Definition: Point.cs:924
bool IsValid
Definition: Point.cs:88
Effect PlayEffect(string id)
Definition: Point.cs:1254
bool HasObj
Definition: Point.cs:137
int Distance(Point p)
Definition: Point.cs:995
bool IsHidden
Definition: Point.cs:347
Chara FirstChara
Definition: Point.cs:288
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Point GetRandomNeighbor()
Definition: Point.cs:764
bool HasChara
Definition: Point.cs:238
bool IsDeepWater
Definition: Point.cs:276
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:774
bool IsActive(int id, int days=-1)
static string GetRandomPortrait(string idDict)
Definition: Portrait.cs:155
static HashSet< string > allIds
Definition: Portrait.cs:34
PropsInstalled installed
Definition: PropsManager.cs:8
List< Card > sales
Definition: PropsManager.cs:14
TraitManager traits
Definition: Props.cs:18
List< Thing > containers
Definition: Props.cs:22
PropSet all
Definition: Props.cs:8
bool paid
Definition: QuestDebt.cs:10
int stage
Definition: QuestDebt.cs:13
int uidChara
Definition: QuestEscort.cs:6
List< Quest > list
Definition: QuestManager.cs:11
bool OnShowDialog(Chara c)
Quest Add(string id, string idGlobalChara=null)
Definition: QuestManager.cs:29
bool IsStarted(string id)
int GetPhase(string id)
Quest Get(string id)
Definition: Quest.cs:7
virtual void OnGiveItem(Chara c, Thing t)
Definition: Quest.cs:536
int phase
Definition: Quest.cs:40
void NextPhase()
Definition: Quest.cs:572
void ChangePhase(int a)
Definition: Quest.cs:577
void Complete()
Definition: Quest.cs:473
void OnSetGoal(AIAct newGoal)
Definition: QueueManager.cs:23
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49
static void UseSeed(int seed, Action action)
Definition: Rand.cs:24
static void SetSeed(int a=-1)
Definition: Rand.cs:44
Definition: Recipe.cs:7
static int Set(Zone zone)
Definition: RefZone.cs:12
static Zone Get(int uid)
Definition: RefZone.cs:3
List< Zone > ListTowns()
Definition: Region.cs:273
Dictionary< string, Religion > dictAll
ReligionMoonShadow MoonShadow
ReligionTrickery Trickery
ReligionHealing Healing
Religion GetRandomReligion(bool onlyJoinable=true, bool includeMinor=false)
static Religion recentWrath
Definition: Religion.cs:29
virtual void Revelation(string idTalk, Card c, int chance=100)
Definition: Religion.cs:167
virtual string NameShort
Definition: Religion.cs:55
virtual string Name
Definition: Religion.cs:37
int ConvertTile(int tile)
Definition: RenderData.cs:111
SourceMaterial.Row mat
Definition: RenderParam.cs:17
SpriteReplacer replacer
Definition: RenderRow.cs:89
bool multisize
Definition: RenderRow.cs:64
SourcePref pref
Definition: RenderRow.cs:68
bool ContainsTag(string _tag)
Definition: RenderRow.cs:159
TileType tileType
Definition: RenderRow.cs:77
int[] _tiles
Definition: RenderRow.cs:12
int[] tiles
Definition: RenderRow.cs:10
Sprite GetSprite(int dir=0, int skin=0, bool snow=false)
Definition: RenderRow.cs:283
void AssignCharas()
Definition: RoomManager.cs:39
Definition: Room.cs:4
Definition: Scene.cs:8
ParticleSystem psSmoke
Definition: Scene.cs:113
GameScreen screenElin
Definition: Scene.cs:93
ActionMode actionMode
Definition: Scene.cs:79
ParticleSystem psFoot
Definition: Scene.cs:111
EloMap elomap
Definition: Scene.cs:149
PointTarget mouseTarget
Definition: Scene.cs:135
bool paused
Definition: Scene.cs:140
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
List< Row > listSister
string[] works
Definition: SourceChara.cs:47
string[] hobbies
Definition: SourceChara.cs:49
static Row rowDefaultPCC
Definition: SourceChara.cs:158
List< Row > listWorks
Definition: SourceHobby.cs:112
List< Row > listHobbies
Definition: SourceHobby.cs:109
string[] weapon
Definition: SourceJob.cs:37
string equip
Definition: SourceJob.cs:39
string id
Definition: SourceJob.cs:9
SourceMaterial materials
SourceRace races
SourceThing things
SourceHobby hobbies
SourceCharaText charaText
SourceBacker backers
SourceCategory categories
SourceElement elements
SourceChara charas
SourceJob jobs
SourceReligion religions
SourceTactics tactics
bool Surface
Definition: SourcePref.cs:369
string meleeStyle
Definition: SourceRace.cs:75
string castStyle
Definition: SourceRace.cs:77
Zone Find(string id)
GlobalSpatialList map
int lv
Definition: Spatial.cs:142
int uid
Definition: Spatial.cs:70
virtual bool ShowDangerLv
Definition: Spatial.cs:503
virtual bool IsRegion
Definition: Spatial.cs:515
virtual string Name
Definition: Spatial.cs:509
virtual int DangerLvBoost
Definition: Spatial.cs:489
virtual bool IsSnowCovered
Definition: Spatial.cs:545
SourceZone.Row source
Definition: Spatial.cs:453
bool destryoed
Definition: Spatial.cs:45
string id
Definition: Spatial.cs:13
int development
Definition: Spatial.cs:238
bool isConquered
Definition: Spatial.cs:382
bool isPeace
Definition: Spatial.cs:406
int influence
Definition: Spatial.cs:214
List< Spatial > children
Definition: Spatial.cs:37
Zone FindZone(int lv)
Definition: Spatial.cs:728
Definition: SPELL.cs:710
bool tryFixPrefNotLoadedAtStart
Definition: SpriteData.cs:34
void LoadPrefAndFixDensity()
Definition: SpriteData.cs:70
SourcePref pref
Definition: SpriteData.cs:32
SpriteData data
Sprite GetSprite(string suffix="")
static int GetAffinityMod(int phase)
Definition: StatsHygiene.cs:19
Definition: Stats.cs:5
static StatsSAN SAN
Definition: Stats.cs:46
static StatsSleepiness Sleepiness
Definition: Stats.cs:21
virtual void Mod(int a)
Definition: Stats.cs:135
static StatsHygiene Hygiene
Definition: Stats.cs:36
static StatsBurden Burden
Definition: Stats.cs:11
Stats Set(int[] _raw, int _rawIndex, Chara _CC)
Definition: Stats.cs:109
override int GetPhase()
Definition: Stats.cs:117
static StatsMana Mana
Definition: Stats.cs:41
virtual int value
Definition: Stats.cs:56
static StatsStamina Stamina
Definition: Stats.cs:16
static Stats Depression
Definition: Stats.cs:26
static StatsHunger Hunger
Definition: Stats.cs:6
virtual int max
Definition: Stats.cs:68
static Stats Bladder
Definition: Stats.cs:31
Definition: Steam.cs:12
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:53
static SubPassData Default
Definition: SubPassData.cs:7
Definition: TC.cs:4
int DestDist
Definition: Tactics.cs:24
static TargetTypeSelfParty SelfParty
Definition: TargetType.cs:9
virtual bool ForceParty
Definition: TargetType.cs:41
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
void DestroyAll(Func< Thing, bool > funcExclude=null)
Thing Find(int uid)
void Foreach(Action< Thing > action, bool onlyAccessible=true)
static void TryLickChest(Thing chest)
Definition: ThingGen.cs:453
static Thing CreateTreasure(string id, int lv, TreasureType type=TreasureType.Map)
Definition: ThingGen.cs:264
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static Thing CreateSpellbook(string alias, int num=1)
Definition: ThingGen.cs:159
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing CreateScroll(int ele, int num=1)
Definition: ThingGen.cs:190
static Thing CreateCurrency(int a, string id="money")
Definition: ThingGen.cs:37
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
bool isEquipped
Definition: Thing.cs:17
override int SelfWeight
Definition: Thing.cs:64
override int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Thing.cs:829
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:532
override SourcePref Pref
Definition: Thing.cs:50
bool IsSharedContainer
Definition: Thing.cs:110
Thing Identify(bool show=true, IDTSource idtSource=IDTSource.Identify)
Definition: Thing.cs:2155
void Set(string n)
bool ignoreSnow
Definition: TileRow.cs:7
string soundFoot
Definition: TileRow.cs:15
virtual bool IsWater
Definition: TileType.cs:171
static Span GetSpan(string id, int hour)
Definition: TimeTable.cs:45
void AddHolder(Chara c)
Definition: TraitBed.cs:107
bool IsHolder(Chara c)
Definition: TraitBed.cs:135
bool CanAssign(Chara c)
Definition: TraitBed.cs:165
virtual Adv_Type AdvType
Definition: TraitChara.cs:102
virtual bool UseRandomName
Definition: TraitChara.cs:134
virtual bool UseRandomAlias
Definition: TraitChara.cs:136
virtual bool CanBePushed
Definition: TraitChara.cs:120
virtual SourceElement.Row source
Definition: TraitScroll.cs:5
virtual bool IsAmmo(Thing t)
virtual bool CanExtendBuild
Definition: Trait.cs:181
virtual bool IsBlockPath
Definition: Trait.cs:54
virtual void OnTickHeld()
Definition: Trait.cs:1247
virtual void OnSteppedOut(Chara c)
Definition: Trait.cs:1281
virtual bool IgnoreOnSteppedWhenMoving
Definition: Trait.cs:383
virtual bool CanBeDestroyed
Definition: Trait.cs:307
virtual bool CanRead(Chara c)
Definition: Trait.cs:1166
virtual ShopType ShopType
Definition: Trait.cs:534
virtual bool IsDoor
Definition: Trait.cs:58
virtual bool CanEat(Chara c)
Definition: Trait.cs:1175
virtual bool IsChangeFloorHeight
Definition: Trait.cs:74
virtual void OnStepped(Chara c)
Definition: Trait.cs:1277
Card owner
Definition: Trait.cs:28
virtual bool CanBeDropped
Definition: Trait.cs:313
virtual Action GetHealAction(Chara c)
Definition: Trait.cs:639
virtual void SetName(ref string s)
Definition: Trait.cs:737
virtual bool CanDrink(Chara c)
Definition: Trait.cs:1184
virtual bool CanOnlyCarry
Definition: Trait.cs:305
virtual void OnBlend(Thing t, Chara c)
Definition: Trait.cs:649
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
static void Play(string idStep)
Definition: Tutorial.cs:7
Definition: UIItem.cs:5
Image image2
Definition: UIItem.cs:16
UIText text2
Definition: UIItem.cs:8
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
Definition: UINote.cs:6
UIItem AddHeaderCard(string text, Sprite sprite=null)
Definition: UINote.cs:84
void Clear()
Definition: UINote.cs:35
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Build()
Definition: UINote.cs:49
void SetText(string s)
Definition: UIText.cs:163
int uidZone
Definition: UniqueData.cs:12
bool IsRealTime
Definition: VirtualDate.cs:7
Condition
Definition: Weather.cs:16
Condition CurrentCondition
Definition: Weather.cs:79
bool IsRaining
Definition: Weather.cs:117
static void Say(string text, FontColor fontColor=FontColor.Default, Sprite sprite=null)
FilterResult IsFilterPass(string text)
Definition: Window.cs:498
ContainerFlag flag
Definition: Window.cs:267
HashSet< int > cats
Definition: Window.cs:119
bool userFilter
Definition: Window.cs:132
bool noRotten
Definition: Window.cs:439
bool advDistribution
Definition: Window.cs:427
Definition: Window.cs:13
int efficiency
Definition: WorkSession.cs:28
WorkSession work
Definition: WorkSummary.cs:10
List< WorkSession > hobbies
Definition: WorkSummary.cs:13
Region region
Definition: World.cs:23
GameDate date
Definition: World.cs:6
void SendPackage(Thing p)
Definition: World.cs:68
Weather weather
Definition: World.cs:12
void OnCharaDie(Chara c)
virtual ZoneTransition.EnterState ReturnState
Definition: ZoneInstance.cs:26
virtual void OnLeaveZone()
Definition: ZoneInstance.cs:36
bool IsCrystalLv
Definition: Zone_Nymelle.cs:25
Definition: Zone.cs:12
bool isSimulating
Definition: Zone.cs:78
void RefreshDeathSentense()
Definition: Zone.cs:1200
ZoneEventManager events
Definition: Zone.cs:43
virtual bool IsNefia
Definition: Zone.cs:292
int CountMinions(Chara c)
Definition: Zone.cs:4028
Zone GetTopZone()
Definition: Zone.cs:2107
bool IsPCFactionOrTent
Definition: Zone.cs:483
FactionBranch branch
Definition: Zone.cs:34
virtual bool HasLaw
Definition: Zone.cs:236
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3254
Chara Boss
Definition: Zone.cs:91
bool TryAddThingInSharedContainer(Thing t, List< Thing > containers=null, bool add=true, bool msg=false, Chara chara=null, bool sharedOnly=true)
Definition: Zone.cs:2308
virtual bool IsFestival
Definition: Zone.cs:216
virtual bool IsTown
Definition: Zone.cs:230
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2980
void RemoveCard(Card t)
Definition: Zone.cs:2191
bool IsActiveZone
Definition: Zone.cs:502
virtual bool PetFollow
Definition: Zone.cs:294
override int DangerLv
Definition: Zone.cs:115
bool IsPCFaction
Definition: Zone.cs:480
void ResetHostility()
Definition: Zone.cs:2914
virtual bool IsUnderwater
Definition: Zone.cs:276
ZoneInstance instance
Definition: Zone.cs:58
virtual bool WillAutoSave
Definition: Zone.cs:270
virtual bool KeepAllyDistance
Definition: Zone.cs:309
virtual bool HiddenInRegionMap
Definition: Zone.cs:420
void RefreshListCitizen()
Definition: Zone.cs:3867
Card AddCard(Card t, Point point)
Definition: Zone.cs:2151
Map map
Definition: Zone.cs:66
Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState=ZoneTransition.EnterState.Auto)
Definition: Zone.cs:1492
NoteMode
Definition: IInspect.cs:7
Definition: ActRef.cs:2
Definition: ACT.cs:71
CostType type
Definition: ACT.cs:74
int cost
Definition: ACT.cs:72
uint Bits
Definition: BitArray32.cs:6