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