Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitWell.cs
Go to the documentation of this file.
1public class TraitWell : Trait
2{
3 public bool IsHoly => this is TraitWellHoly;
4
5 public override bool IsBlendBase => true;
6
7 public override bool HasCharges => true;
8
9 public override bool ShowCharges => false;
10
11 public int pollution => owner.GetInt(26);
12
13 public int Charges
14 {
15 get
16 {
17 if (!IsHoly)
18 {
19 return owner.c_charges;
20 }
21 return EClass.player.holyWell;
22 }
23 set
24 {
25 if (IsHoly)
26 {
27 EClass.player.holyWell = value;
28 }
29 else
30 {
31 owner.c_charges = value;
32 }
33 }
34 }
35
36 public bool polluted => pollution >= 10;
37
38 public override bool CanBlend(Thing t)
39 {
40 return t.category.IsChildOf("drink");
41 }
42
43 public override void OnBlend(Thing t, Chara c)
44 {
45 bool flag = polluted;
46 if (!IsHoly)
47 {
48 ModCharges(1);
49 }
50 if ((t.id == "water" || t.id == "bucket") && t.IsBlessed)
51 {
52 if (IsHoly)
53 {
54 ModCharges(1);
55 }
56 if (polluted)
57 {
58 Msg.Say("unpolluted", owner);
59 Charges = 1;
60 }
61 owner.SetInt(26);
62 }
63 else
64 {
65 string name = owner.Name;
66 owner.SetInt(26, pollution + EClass.rnd(3) + ((t.blessedState <= BlessedState.Cursed) ? 10 : 0) + (IsHoly ? 10 : 0));
67 if (!flag && polluted)
68 {
69 Msg.Say("polluted", name);
70 }
71 }
72 t.ModNum(-1);
73 }
74
75 public override void OnCreate(int lv)
76 {
77 if (!IsHoly)
78 {
79 owner.c_charges = EClass.rnd(6) + 2;
80 }
81 }
82
83 public override void TrySetAct(ActPlan p)
84 {
85 p.TrySetAct("actDrink", delegate
86 {
87 if (Charges <= 0)
88 {
89 EClass.pc.Say("drinkWell_empty", EClass.pc, owner);
90 return false;
91 }
92 EClass.pc.Say("drinkWell", EClass.pc, owner);
93 EClass.pc.PlaySound("drink");
94 EClass.pc.PlayAnime(AnimeID.Shiver);
95 if (IsHoly || EClass.rnd(5) == 0)
96 {
97 ActEffect.Proc(EffectId.ModPotential, EClass.pc, null, (!polluted && (IsHoly || EClass.rnd(2) == 0)) ? 100 : (-100));
98 }
99 else if (EClass.rnd(5) == 0)
100 {
101 BadEffect(EClass.pc);
102 }
103 else if (EClass.rnd(4) == 0)
104 {
105 ActEffect.Proc(EffectId.Mutation, EClass.pc);
106 }
107 else if (EClass.rnd(EClass.debug.enable ? 2 : 10) == 0 && !polluted && !EClass.player.wellWished)
108 {
109 if (EClass.player.CountKeyItem("well_wish") > 0)
110 {
111 EClass.player.ModKeyItem("well_wish", -1);
112 ActEffect.Proc(EffectId.Wish, EClass.pc, null, 10 + EClass.player.CountKeyItem("well_enhance") * 10);
113 EClass.player.wellWished = true;
114 }
115 else
116 {
117 Msg.SayNothingHappen();
118 }
119 }
120 else if (polluted)
121 {
122 EClass.pc.Say("drinkWater_dirty");
124 }
125 else
126 {
127 EClass.pc.Say("drinkWater_clear");
128 }
129 ModCharges(-1);
130 return true;
131 }, owner);
132 }
133
134 public void ModCharges(int a)
135 {
136 Charges += a;
137 if (Charges <= 0)
138 {
139 EClass.pc.Say("drinkWell_dry", EClass.pc, owner);
140 }
141 }
142
143 public static void BadEffect(Chara c)
144 {
145 switch (EClass.rnd(7))
146 {
147 case 0:
148 ActEffect.Proc(EffectId.Blind, c);
149 break;
150 case 1:
151 ActEffect.Proc(EffectId.Paralyze, c);
152 break;
153 case 2:
154 ActEffect.Proc(EffectId.Sleep, c);
155 break;
156 case 3:
157 ActEffect.Proc(EffectId.Poison, c);
158 break;
159 case 4:
160 ActEffect.Proc(EffectId.Faint, c);
161 break;
162 case 5:
163 ActEffect.Proc(EffectId.Disease, c);
164 break;
165 default:
166 ActEffect.Proc(EffectId.Confuse, c);
167 break;
168 }
169 }
170
171 public override void SetName(ref string s)
172 {
173 if (polluted)
174 {
175 s = "_polluted".lang(s);
176 }
177 }
178}
AnimeID
Definition: AnimeID.cs:2
BlessedState
Definition: BlessedState.cs:2
EffectId
Definition: EffectId.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
static void Proc(EffectId id, Card cc, Card tc=null, int power=100, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:788
bool TrySetAct(string lang, Func< bool > onPerform, Card tc, CursorInfo cursor=null, int dist=1, bool isHostileAct=false, bool localAct=true, bool canRepeat=false)
Definition: ActPlan.cs:344
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
string id
Definition: Card.cs:31
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
string Name
Definition: Card.cs:2013
BlessedState blessedState
Definition: Card.cs:262
bool IsBlessed
Definition: Card.cs:2113
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:5423
SourceCategory.Row category
Definition: Card.cs:1925
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
int c_charges
Definition: Card.cs:1205
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
bool enable
Definition: CoreDebug.cs:285
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
bool wellWished
Definition: Player.cs:784
int holyWell
Definition: Player.cs:724
Definition: Thing.cs:8
override bool IsBlendBase
Definition: TraitWell.cs:5
static void BadEffect(Chara c)
Definition: TraitWell.cs:143
bool polluted
Definition: TraitWell.cs:36
override void TrySetAct(ActPlan p)
Definition: TraitWell.cs:83
override bool ShowCharges
Definition: TraitWell.cs:9
override void SetName(ref string s)
Definition: TraitWell.cs:171
bool IsHoly
Definition: TraitWell.cs:3
override bool HasCharges
Definition: TraitWell.cs:7
override void OnCreate(int lv)
Definition: TraitWell.cs:75
int Charges
Definition: TraitWell.cs:14
void ModCharges(int a)
Definition: TraitWell.cs:134
override void OnBlend(Thing t, Chara c)
Definition: TraitWell.cs:43
int pollution
Definition: TraitWell.cs:11
override bool CanBlend(Thing t)
Definition: TraitWell.cs:38
Definition: Trait.cs:7
Card owner
Definition: Trait.cs:26