Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitBaseSpellbook.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.CompilerServices;
5using UnityEngine;
6
7// Token: 0x0200035E RID: 862
9{
10 // Token: 0x170007D1 RID: 2001
11 // (get) Token: 0x06001ABA RID: 6842 RVA: 0x000A60C0 File Offset: 0x000A42C0
12 public virtual TraitBaseSpellbook.Type BookType
13 {
14 get
15 {
16 return TraitBaseSpellbook.Type.Spell;
17 }
18 }
19
20 // Token: 0x170007D2 RID: 2002
21 // (get) Token: 0x06001ABB RID: 6843 RVA: 0x000A60C3 File Offset: 0x000A42C3
22 public virtual int Difficulty
23 {
24 get
25 {
26 return 10 + this.owner.LV;
27 }
28 }
29
30 // Token: 0x06001ABC RID: 6844 RVA: 0x000A60D3 File Offset: 0x000A42D3
31 public override bool CanRead(Chara c)
32 {
33 return !c.isBlind;
34 }
35
36 // Token: 0x170007D3 RID: 2003
37 // (get) Token: 0x06001ABD RID: 6845 RVA: 0x000A60DE File Offset: 0x000A42DE
38 public override bool CanStack
39 {
40 get
41 {
42 return false;
43 }
44 }
45
46 // Token: 0x170007D4 RID: 2004
47 // (get) Token: 0x06001ABE RID: 6846 RVA: 0x000A60E1 File Offset: 0x000A42E1
48 public override bool HasCharges
49 {
50 get
51 {
52 return true;
53 }
54 }
55
56 // Token: 0x170007D5 RID: 2005
57 // (get) Token: 0x06001ABF RID: 6847 RVA: 0x000A60E4 File Offset: 0x000A42E4
58 public override float MTPValue
59 {
60 get
61 {
62 return 10f;
63 }
64 }
65
66 // Token: 0x06001AC0 RID: 6848 RVA: 0x000A60EB File Offset: 0x000A42EB
67 public override int GetActDuration(Chara c)
68 {
69 return Mathf.Max(this.Difficulty, 100) * Mathf.Max(100 - (int)Mathf.Sqrt((float)c.Evalue(285)) * 7, 10) / 400;
70 }
71
72 // Token: 0x06001AC1 RID: 6849 RVA: 0x000A6120 File Offset: 0x000A4320
73 public override void OnCreate(int lv)
74 {
75 this.owner.c_charges = 1 + EClass.rnd(4) + EClass.rnd(EClass.rnd(4) + 1);
76 switch (this.BookType)
77 {
78 case TraitBaseSpellbook.Type.Ancient:
79 {
80 int max = Lang.GetList("ancientbook").Length;
81 this.owner.refVal = EClass.rnd(Mathf.Clamp(EClass.rnd(lv / 5 + 5), 1, max));
82 return;
83 }
84 case TraitBaseSpellbook.Type.Spell:
85 break;
86 case TraitBaseSpellbook.Type.RandomSpell:
87 this.owner.refVal = TraitBaseSpellbook.selecter.Select(lv);
88 return;
89 case TraitBaseSpellbook.Type.Ero:
90 {
91 IEnumerable<SourceChara.Row> ie = from a in EClass.sources.charas.rows
92 where !a.name.IsEmpty() && a.name.Length > 2 && a.name[0] != '<' && a.race != "god"
93 select a;
94 this.owner.c_idRefName = ie.RandomItem<SourceChara.Row>().id;
95 return;
96 }
97 case TraitBaseSpellbook.Type.Dojin:
98 this.owner.c_idRefName = EClass.game.religions.dictAll.RandomItem<string, Religion>().id;
99 break;
100 default:
101 return;
102 }
103 }
104
105 // Token: 0x06001AC2 RID: 6850 RVA: 0x000A6228 File Offset: 0x000A4428
106 public override bool TryProgress(AIProgress p)
107 {
108 TraitBaseSpellbook.<>c__DisplayClass15_0 CS$<>8__locals1;
109 CS$<>8__locals1.c = p.owner;
110 if (this.BookType == TraitBaseSpellbook.Type.Ancient && this.owner.isOn)
111 {
112 if (CS$<>8__locals1.c.IsPC)
113 {
114 CS$<>8__locals1.c.Say("alreadyDecoded", null, null);
115 }
116 return false;
117 }
118 if (CS$<>8__locals1.c.isBlind)
119 {
120 CS$<>8__locals1.c.Say("blinded", CS$<>8__locals1.c, null, null);
121 return false;
122 }
123 CS$<>8__locals1.diff = Mathf.Max(1, this.Difficulty * ((this.owner.blessedState >= BlessedState.Blessed) ? 75 : ((this.owner.blessedState <= BlessedState.Cursed) ? 300 : 100)) / 100);
124 CS$<>8__locals1.check = Mathf.Max(1, CS$<>8__locals1.c.Evalue(this.eleParent) * (100 + CS$<>8__locals1.c.Evalue(285) * 10) / 100);
125 if (TraitBaseSpellbook.<TryProgress>g__ReadCheck|15_0(ref CS$<>8__locals1) || EClass.debug.godMode || this.owner.HasEditorTag(EditorTag.NoReadFail))
126 {
127 return true;
128 }
129 TraitBaseSpellbook.ReadFailEffect(CS$<>8__locals1.c);
130 this.ModCharge(CS$<>8__locals1.c, -1);
131 return false;
132 }
133
134 // Token: 0x06001AC3 RID: 6851 RVA: 0x000A635C File Offset: 0x000A455C
135 public static void ReadFailEffect(Chara c)
136 {
137 if (EClass.rnd(2) == 0)
138 {
139 c.Say("spell_fail_mana", c, null, null);
140 c.mana.Mod(-c.mana.max / (c.IsPC ? 2 : 5));
141 return;
142 }
143 if (EClass.rnd(3) == 0)
144 {
145 c.Say("spell_fail_confuse", c, null, null);
146 c.AddCondition<ConConfuse>(100, false);
147 return;
148 }
149 if (EClass.rnd(3) == 0)
150 {
151 c.Say("spell_fail_monster", c, null, null);
152 c.PlaySound("spell_funnel", 1f, true);
153 for (int i = 0; i < 1 + EClass._zone.DangerLv / 15 + EClass.rnd(3 + EClass._zone.DangerLv / 15); i++)
154 {
155 Chara chara = CharaGen.CreateFromFilter("c_readFail", EClass._zone.DangerLv, -1);
156 EClass._zone.AddCard(chara, c.pos.GetNearestPoint(false, false, true, false));
157 chara.pos.PlayEffect("teleport");
158 }
159 return;
160 }
161 c.Say("spell_fail_teleport", c, null, null);
162 if (c.IsPCFaction && !c.IsPC)
163 {
164 c.SayNothingHappans();
165 return;
166 }
167 ActEffect.Proc(EffectId.Teleport, c, null, 100, default(ActRef));
168 }
169
170 // Token: 0x06001AC4 RID: 6852 RVA: 0x000A64A0 File Offset: 0x000A46A0
171 public override void OnRead(Chara c)
172 {
173 bool flag = this.BookType == TraitBaseSpellbook.Type.Spell || this.BookType == TraitBaseSpellbook.Type.RandomSpell;
174 int a = -1;
175 if (c.IsPCParty)
176 {
177 Thing thing = this.owner.Thing;
178 if (thing != null)
179 {
180 thing.Identify(true, IDTSource.SuperiorIdentify);
181 }
182 this.owner.isOn = true;
183 }
184 switch (this.BookType)
185 {
186 case TraitBaseSpellbook.Type.Ancient:
187 c.Say("book_decode", c, this.owner, null, null);
188 if (!c.IsPC)
189 {
190 this.ModCharge(c, -this.owner.c_charges);
191 }
192 if (c.IsPC)
193 {
194 Guild.Mage.AddContribution(5 + this.owner.refVal * 2);
195 }
196 break;
197 case TraitBaseSpellbook.Type.Spell:
198 case TraitBaseSpellbook.Type.RandomSpell:
199 if (c.IsPC)
200 {
201 c.GainAbility(this.source.id, 100);
202 }
203 this.ModCharge(c, -1);
204 break;
205 case TraitBaseSpellbook.Type.Ero:
206 case TraitBaseSpellbook.Type.Dojin:
207 {
208 c.PlaySound("wow", 1f, true);
209 c.Say("book_decode", c, this.owner, null, null);
210 if (!c.IsPC)
211 {
212 c.Talk("wow", null, null, false);
213 }
214 TraitBaseSpellbook.Type bookType = this.BookType;
215 if (bookType != TraitBaseSpellbook.Type.Ero)
216 {
217 if (bookType == TraitBaseSpellbook.Type.Dojin)
218 {
219 Religion religion = EClass.game.religions.dictAll.TryGetValue(this.owner.c_idRefName, null) ?? EClass.game.religions.Eyth;
220 if (c.IsPC)
221 {
222 EClass.player.ModKarma(-1);
223 }
224 c.AddCondition<ConInsane>(500, false);
225 c.AddCondition<ConFaint>(100, false);
226 if (!c.IsPC && c.faith != religion)
227 {
228 if (!c.source.faith.IsEmpty())
229 {
230 c.Say("faith_stands", c, null, null);
231 }
232 else
233 {
234 religion.JoinFaith(c);
235 a = -this.owner.c_charges;
236 }
237 }
238 }
239 }
240 else
241 {
242 if (c.IsPC)
243 {
244 EClass.pc.SAN.Mod(-(EClass.rnd(5) + 1));
245 }
246 if (!this.owner.c_idRefName.IsEmpty())
247 {
248 CardRow cardRow = EClass.sources.cards.map[this.owner.c_idRefName];
249 c.Say("learn_weakspot", c, cardRow.GetName(), null);
250 if (c.IsPC)
251 {
252 EClass.player.codex.AddWeakspot(cardRow.id);
253 }
254 }
255 ActEffect.Proc(EffectId.Sleep, c, null, 100, default(ActRef));
256 }
257 this.ModCharge(c, a);
258 break;
259 }
260 }
261 c.ModExp(285, 180);
262 if (flag)
263 {
264 c.ModExp(307, 200);
265 }
266 if (c.IsPC)
267 {
268 LayerAbility.Redraw();
269 }
270 }
271
272 // Token: 0x06001AC5 RID: 6853 RVA: 0x000A6770 File Offset: 0x000A4970
273 public void ModCharge(Chara c, int a = -1)
274 {
275 this.owner.ModCharge(a, false);
276 LayerInventory.SetDirtyAll(false);
277 if (this.owner.c_charges <= 0)
278 {
279 c.Say("spellbookCrumble", this.owner, null, null);
280 this.owner.ModNum(-1, true);
281 }
282 }
283
284 // Token: 0x06001AC6 RID: 6854 RVA: 0x000A67C0 File Offset: 0x000A49C0
285 public override void SetName(ref string s)
286 {
287 if (!this.owner.IsIdentified)
288 {
289 return;
290 }
291 TraitBaseSpellbook.Type bookType = this.BookType;
292 if (bookType != TraitBaseSpellbook.Type.Ancient)
293 {
294 if (bookType - TraitBaseSpellbook.Type.Ero > 1)
295 {
296 return;
297 }
298 string c_idRefName = this.owner.c_idRefName;
299 if (c_idRefName.IsEmpty())
300 {
301 return;
302 }
303 string @ref = (this.BookType == TraitBaseSpellbook.Type.Dojin) ? EClass.game.religions.dictAll[c_idRefName].Name : EClass.sources.charas.map[c_idRefName].GetName();
304 s = "_'s".lang(@ref, s, null, null, null);
305 }
306 else
307 {
308 s = "_titled".lang(Lang.GetList("ancientbook")[this.owner.refVal], s, null, null, null);
309 if (this.owner.isOn)
310 {
311 s = "_deciphered ".lang(s, null, null, null, null);
312 return;
313 }
314 }
315 }
316
317 // Token: 0x06001AC9 RID: 6857 RVA: 0x000A68C0 File Offset: 0x000A4AC0
318 [CompilerGenerated]
319 internal static bool <TryProgress>g__ReadCheck|15_0(ref TraitBaseSpellbook.<>c__DisplayClass15_0 A_0)
320 {
321 return (EClass.rnd(4) == 0 || (!A_0.c.isConfused && !A_0.c.HasCondition<ConDim>())) && (A_0.check > A_0.diff * 3 || EClass.rnd(A_0.check * 30) >= A_0.diff);
322 }
323
324 // Token: 0x040010BC RID: 4284
325 public static ElementSelecter selecter = new ElementSelecter
326 {
327 type = "B",
328 useDomain = true
329 };
330
331 // Token: 0x02000997 RID: 2455
332 public enum Type
333 {
334 // Token: 0x0400280D RID: 10253
335 Ancient,
336 // Token: 0x0400280E RID: 10254
337 Spell,
338 // Token: 0x0400280F RID: 10255
339 RandomSpell,
340 // Token: 0x04002810 RID: 10256
341 Ero,
342 // Token: 0x04002811 RID: 10257
343 Dojin
344 }
345}
Definition Chara.cs:12
Definition Guild.cs:5
Definition Thing.cs:10