12 public virtual TraitBaseSpellbook.Type BookType
22 public virtual int Difficulty
26 return 10 + this.owner.LV;
31 public override bool CanRead(
Chara c)
38 public override bool CanStack
48 public override bool HasCharges
58 public override float MTPValue
67 public override int GetActDuration(
Chara c)
69 return Mathf.Max(this.Difficulty, 100) * Mathf.Max(100 - (
int)Mathf.Sqrt((
float)c.Evalue(285)) * 7, 10) / 400;
73 public override void OnCreate(
int lv)
76 switch (this.BookType)
80 int max = Lang.GetList(
"ancientbook").Length;
81 this.owner.refVal =
EClass.rnd(Mathf.Clamp(
EClass.rnd(lv / 5 + 5), 1, max));
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"
98 this.owner.c_idRefName =
EClass.game.religions.dictAll.RandomItem<string,
Religion>().
id;
106 public override bool TryProgress(
AIProgress p)
109 CS$<>8__locals1.c = p.owner;
112 if (CS$<>8__locals1.c.IsPC)
114 CS$<>8__locals1.c.Say(
"alreadyDecoded",
null,
null);
118 if (CS$<>8__locals1.c.isBlind)
120 CS$<>8__locals1.c.Say(
"blinded", CS$<>8__locals1.c,
null,
null);
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))
130 this.ModCharge(CS$<>8__locals1.c, -1);
135 public static void ReadFailEffect(
Chara c)
139 c.Say(
"spell_fail_mana", c,
null,
null);
140 c.mana.Mod(-c.mana.max / (c.IsPC ? 2 : 5));
145 c.Say(
"spell_fail_confuse", c,
null,
null);
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++)
156 EClass._zone.AddCard(chara, c.pos.GetNearestPoint(
false,
false,
true,
false));
157 chara.pos.PlayEffect(
"teleport");
161 c.Say(
"spell_fail_teleport", c,
null,
null);
162 if (c.IsPCFaction && !c.IsPC)
164 c.SayNothingHappans();
171 public override void OnRead(
Chara c)
173 bool flag = this.BookType == TraitBaseSpellbook.Type.Spell || this.BookType ==
TraitBaseSpellbook.Type.RandomSpell;
177 Thing thing = this.owner.Thing;
180 thing.Identify(
true, IDTSource.SuperiorIdentify);
182 this.owner.isOn =
true;
184 switch (this.BookType)
187 c.Say(
"book_decode", c, this.owner,
null,
null);
190 this.ModCharge(c, -this.owner.c_charges);
194 Guild.Mage.AddContribution(5 + this.owner.refVal * 2);
201 c.GainAbility(this.source.id, 100);
203 this.ModCharge(c, -1);
208 c.PlaySound(
"wow", 1f,
true);
209 c.Say(
"book_decode", c, this.owner,
null,
null);
212 c.Talk(
"wow",
null,
null,
false);
214 TraitBaseSpellbook.Type bookType = this.BookType;
219 Religion religion =
EClass.game.religions.dictAll.TryGetValue(this.owner.c_idRefName,
null) ??
EClass.game.religions.Eyth;
222 EClass.player.ModKarma(-1);
225 c.AddCondition<
ConFaint>(100,
false);
226 if (!c.IsPC && c.faith != religion)
228 if (!c.source.faith.IsEmpty())
230 c.Say(
"faith_stands", c,
null,
null);
234 religion.JoinFaith(c);
235 a = -this.owner.c_charges;
246 if (!this.owner.c_idRefName.IsEmpty())
248 CardRow cardRow =
EClass.sources.cards.map[this.owner.c_idRefName];
249 c.Say(
"learn_weakspot", c, cardRow.GetName(),
null);
252 EClass.player.codex.AddWeakspot(cardRow.id);
257 this.ModCharge(c, a);
273 public void ModCharge(
Chara c,
int a = -1)
275 this.owner.ModCharge(a,
false);
277 if (this.owner.c_charges <= 0)
279 c.Say(
"spellbookCrumble", this.owner,
null,
null);
280 this.owner.ModNum(-1,
true);
285 public override void SetName(ref
string s)
287 if (!this.owner.IsIdentified)
291 TraitBaseSpellbook.Type bookType = this.BookType;
298 string c_idRefName = this.owner.c_idRefName;
299 if (c_idRefName.IsEmpty())
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);
308 s =
"_titled".lang(Lang.GetList(
"ancientbook")[
this.owner.refVal], s,
null,
null,
null);
311 s =
"_deciphered ".lang(s,
null,
null,
null,
null);
319 internal static bool <TryProgress>g__ReadCheck|15_0(ref
TraitBaseSpellbook.<>c__DisplayClass15_0 A_0)
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);