1-- handle the mind school
2--blind/paralysis? wouldn't probably make noticable diff from conf/sleep!
3--((static: res insanity/effects))
4
5function get_psiblast_dam()
6--	return 4 + get_level(Ind, MMINDBLAST, 4), 3 + get_level(Ind, MMINDBLAST, 45) <- just 50% of targetted value
7--	return 2 + get_level(Ind, MMINDBLAST, 6), 3 + get_level(Ind, MMINDBLAST, 45), get_level(Ind, MMINDBLAST, 200)
8	return 2 + get_level(Ind, MMINDBLAST, 7), 3 + get_level(Ind, MMINDBLAST, 45), get_level(Ind, MMINDBLAST, 250)
9end
10
11MSCARE = add_spell {
12	["name"] = 	"Scare",
13        ["school"] = 	{SCHOOL_MINTRUSION},
14        ["am"] = 	50,
15        ["spell_power"] = 0,
16        ["level"] = 	1,
17        ["mana"] = 	1,
18        ["mana_max"] = 	13,
19        ["fail"] = 	10,
20        ["direction"] = function() if get_level(Ind, MSCARE, 50) >= 20 then return FALSE else return TRUE end end,
21        ["spell"] = 	function(args)
22                        if get_level(Ind, MSCARE, 50) >= 20 then
23				project_los(Ind, GF_TURN_ALL, 5 + get_level(Ind, MSCARE, 80), "stares deep into your eyes")
24                        elseif get_level(Ind, MSCARE, 50) >= 10 then
25                                fire_ball(Ind, GF_TURN_ALL, args.dir, 5 + get_level(Ind, MSCARE, 80), 3, "stares deep into your eyes")
26                        else
27                                fire_grid_bolt(Ind, GF_TURN_ALL, args.dir, 5 + get_level(Ind, MSCARE, 80), "stares deep into your eyes")
28                        end
29			end,
30	["info"] = 	function()
31                        if get_level(Ind, MSCARE, 50) >= 10 and get_level(Ind, MSCARE, 50) < 10 then
32	                	return "power "..(5 + get_level(Ind, MSCARE, 80)).." rad 3"
33	                else
34	                	return "power "..(5 + get_level(Ind, MSCARE, 80))
35	                end
36			end,
37        ["desc"] =	{
38                        "Tries to manipulate the mind of a monster to scare it",
39                        "At level 10 it turns into a ball",
40                        "At level 20 it affects all monsters in sight",
41        }
42}
43__lua_MSCARE = MSCARE
44
45MCONFUSE = add_spell {
46	["name"] = 	"Confuse",
47        ["school"] = 	{SCHOOL_MINTRUSION},
48        ["am"] = 	50,
49        ["spell_power"] = 0,
50        ["level"] = 	3,
51        ["mana"] = 	2,
52        ["mana_max"] = 	16,
53        ["fail"] = 	10,
54        ["direction"] = function() if get_level(Ind, MCONFUSE, 50) >= 30 then return FALSE else return TRUE end end,
55        ["spell"] = 	function(args)
56                        if get_level(Ind, MCONFUSE, 50) >= 30 then
57                                project_los(Ind, GF_OLD_CONF, 5 + get_level(Ind, MCONFUSE, 100), "focusses on your mind")
58                        elseif get_level(Ind, MCONFUSE, 50) >= 15 then
59                                fire_ball(Ind, GF_OLD_CONF, args.dir, 5 + get_level(Ind, MCONFUSE, 100), 2, "focusses on your mind")
60                        else
61                                fire_grid_bolt(Ind, GF_OLD_CONF, args.dir, 5 + get_level(Ind, MCONFUSE, 100), "focusses on your mind")
62                        end
63			end,
64	["info"] = 	function()
65                        if get_level(Ind, MCONFUSE, 50) >= 15 and get_level(Ind, MCONFUSE, 50) < 30 then
66	                	return "power "..(5 + get_level(Ind, MCONFUSE, 100)).." rad 2"
67	                else
68	                	return "power "..(5 + get_level(Ind, MCONFUSE, 100))
69	                end
70			end,
71        ["desc"] =	{
72        		"Tries to manipulate the mind of a monster to confuse it",
73                        "At level 15 it turns into a ball",
74                        "At level 30 it affects all monsters in sight",
75        }
76}
77
78MSLEEP = add_spell {
79	["name"] =	"Hypnosis",
80	["school"] =	{SCHOOL_MINTRUSION},
81        ["am"] = 	33,
82        ["spell_power"] = 0,
83	["level"] =	5,
84	["mana"] =	2,
85	["mana_max"] =	16,
86	["fail"] =	10,
87        ["direction"] = function() if get_level(Ind, MSLEEP, 50) >= 20 then return FALSE else return TRUE end end,
88	["spell"] =	function(args)
89			if get_level(Ind, MSLEEP, 50) < 20 then
90				fire_grid_bolt(Ind, GF_OLD_SLEEP, args.dir, 5 + get_level(Ind, MSLEEP, 80), "mumbles softly")
91			else
92				project_los(Ind, GF_OLD_SLEEP, 5 + get_level(Ind, MSLEEP, 80), "mumbles softly")
93			end
94			end,
95	["info"] =	function()
96				return "power "..(5 + get_level(Ind, MSLEEP, 80))
97			end,
98	["desc"] = {
99			"Causes the target to fall asleep instantly",
100--			"Lets monsters next to you fall asleep",
101			"At level 20 it lets all nearby monsters fall asleep",
102	}
103}
104
105MSLOWMONSTER = add_spell {
106        ["name"] =	"Drain Strength",
107        ["school"] =	{SCHOOL_MINTRUSION},
108        ["am"] = 	50,
109        ["spell_power"] = 0,
110        ["level"] =	7,
111        ["mana"] =	10,
112        ["mana_max"] =	30,
113        ["fail"] =	10,
114        ["direction"] = function() if get_level(Ind, MSLOWMONSTER, 50) >= 20 then return FALSE else return TRUE end end,
115        ["spell"] =	function(args)
116                        if get_level(Ind, MSLOWMONSTER, 50) >= 20 then
117				project_los(Ind, GF_OLD_SLOW, 5 + get_level(Ind, MSLOWMONSTER, 100), "drains power from your muscles")
118                        elseif get_level(Ind, MSLOWMONSTER, 50) >= 10 then
119				fire_ball(Ind, GF_OLD_SLOW, args.dir, 5 + get_level(Ind, MSLOWMONSTER, 100), 2, "drains power from your muscles")
120			else
121                                fire_grid_bolt(Ind, GF_OLD_SLOW, args.dir, 5 + get_level(Ind, MSLOWMONSTER, 100), "drains power from your muscles")
122                        end
123                        end,
124        ["info"] =	function()
125			if get_level(Ind, MSLOWMONSTER, 50) >= 20 then
126				return "power "..(5 + get_level(Ind, MSLOWMONSTER, 100))
127			elseif get_level(Ind, MSLOWMONSTER, 50) >= 10 then
128				return "power "..(5 + get_level(Ind, MSLOWMONSTER, 100)).." rad 2"
129			else
130				return "power "..(5 + get_level(Ind, MSLOWMONSTER, 100))
131			end
132                        end,
133        ["desc"] =	{
134                        "Drains power from the muscles of your opponent, slowing it down",
135                        "At level 10 it turns into a ball",
136                        "At level 20 it affects all monsters in sight",
137        }
138}
139
140MMINDBLAST = add_spell {
141	["name"] = 	"Psionic Blast",
142        ["school"] = 	{SCHOOL_MINTRUSION},
143        ["am"] = 	50,
144        ["spell_power"] = 0,
145        ["level"] = 	1,
146        ["mana"] = 	1,
147        ["mana_max"] = 	15,
148        ["fail"] = 	10,
149        ["direction"] = TRUE,
150        ["ftk"] = 2,
151        ["spell"] = 	function(args)
152    			local d, s, p
153    			d, s, p = get_psiblast_dam()
154                        fire_grid_bolt(Ind, GF_PSI, args.dir, damroll(d, s) + p, "")
155			end,
156	["info"] = 	function()
157    			local d, s, p
158    			d, s, p = get_psiblast_dam()
159                	return "power "..d.."d"..s.."+"..p
160			end,
161        ["desc"] =	{
162                        "Blasts the target's mind with psionic energy",
163        }
164}
165
166MPSISTORM = add_spell {
167	["name"] = "Psi Storm",
168	["school"] = {SCHOOL_MINTRUSION},
169	["am"] = 50,
170	["spell_power"] = 0,
171	["level"] = 18,
172	["mana"] = 15,
173	["mana_max"] = 40,
174	["fail"] = 25,
175	["direction"] = TRUE,
176	["spell"] = function(args)
177--	["spell"] = function()
178		fire_cloud(Ind, GF_PSI, args.dir, (33 + get_level(Ind, MPSISTORM, 200)), 3 + get_level(Ind, MPSISTORM, 4), 6 + get_level(Ind, MPSISTORM, 4), 14, " releases a psi storm for")
179--		fire_cloud(Ind, GF_PSI, 0, (1 + get_level(Ind, MPSISTORM, 76)), 2 + get_level(Ind, MPSISTORM, 4), 5 + get_level(Ind, MPSISTORM, 5), 14, " releases a psi storm for")
180--                        fire_wave(Ind, GF_PSI, 0, (1 + get_level(Ind, MPSISTORM, 76)), 2 + get_level(Ind, MPSISTORM, 4), 5 + get_level(Ind, MPSISTORM, 5), 14, EFF_STORM, " releases a psi storm for
181	end,
182	["info"] = function()
183		return "dam "..(33 + get_level(Ind, MPSISTORM, 200)).." rad "..(3 + get_level(Ind, MPSISTORM, 4)).." dur "..(6 + get_level(Ind, MPSISTORM, 4))
184	end,
185	["desc"] = {
186		"A psionic storm that damages and disturbs all minds within an area",
187	}
188}
189
190MSILENCE = add_spell {
191	["name"] = 	"Psychic Suppression",
192        ["school"] = 	{SCHOOL_MINTRUSION},
193        ["am"] = 	50,
194        ["spell_power"] = 0,
195        ["level"] = 	10,
196        ["mana"] = 	50,
197        ["mana_max"] = 	100,
198        ["fail"] = 	10,
199        ["direction"] = TRUE,
200        ["spell"] = 	function(args)
201    			--using this hack to transport 2 parameters at once,
202    			--ok since we use a single-target spell and not a ball
203                        fire_grid_bolt(Ind, GF_SILENCE, args.dir, get_level(Ind, MSILENCE, 63) + ((4 + get_level(Ind, MSILENCE, 4)) * 100), "")
204			end,
205	["info"] = 	function()
206                	return "power "..(get_level(Ind, MSILENCE, 63)).." dur "..(4 + get_level(Ind, MSILENCE, 4))
207			end,
208        ["desc"] =	{
209                        "Drains the target's psychic energy, impacting its ability to cast spells",
210        }
211}
212
213MMAP = add_spell {
214	["name"] =	"Remote Vision",
215	["school"] =	{SCHOOL_MINTRUSION},
216--	["school"] =	{SCHOOL_MINTRUSION, SCHOOL_TCONTACT}
217	["am"] = 	50,
218	["spell_power"] = 0,
219	["level"] =	20,
220	["mana"] =	30,
221	["mana_max"] =	30,
222	["fail"] =	0,
223	["direction"] = FALSE,
224	["spell"] =	function()
225			local pow = get_level(Ind, MMAP)
226			if pow > 15 then pow = 15 end
227			mind_map_level(Ind, pow)
228			end,
229	["info"] =	function()
230			local pow = get_level(Ind, MMAP)
231			if pow > 15 then pow = 15 end
232			return "power "..pow
233			end,
234	["desc"] =	{
235			"Forcefully uses the vision of sentient life forms around.",
236			"*** Will be transferred to allied open",
237			"    minds on the same floor if your",
238			"    Attunement skill is at least 20. ***",
239	}
240}
241
242--[[ Old version, requiring pets. Not cool though. See new variant below!
243MCHARM = add_spell
244{
245	["name"] = 	"Charm",
246        ["school"] = 	{SCHOOL_MINTRUSION},
247        ["am"] = 	50,
248        ["spell_power"] = 0,
249        ["level"] = 	1,
250        ["mana"] = 	1,
251        ["mana_max"] = 	20,
252        ["fail"] = 	10,
253        ["direction"] = function () if get_level(Ind, CHARM, 50) >= 35 then return FALSE else return TRUE end end,
254        ["spell"] = 	function(args)
255                        if get_level(Ind, CHARM, 50) >= 35 then
256                                project_los(Ind, GF_CHARM, 10 + get_level(Ind, CHARM, 150), "mumbles softly")
257                        elseif get_level(Ind, CHARM, 50) >= 15 then
258                                fire_ball(Ind, GF_CHARM, args.dir, 10 + get_level(Ind, CHARM, 150), 3, "mumbles softly")
259                        else
260                                fire_bolt(Ind, GF_CHARM, args.dir, 10 + get_level(Ind, CHARM, 150), "mumbles softly")
261                        end
262
263	end,
264	["info"] = 	function()
265                	return "power "..(10 + get_level(Ind, CHARM, 150))
266	end,
267        ["desc"] =	{
268        		"Tries to manipulate the mind of a monster to make it friendly",
269                        "At level 15 it turns into a ball",
270                        "At level 35 it affects all monsters in sight",
271        }
272}
273]]
274
275-- New idea: works like *invincibility*: monsters will ignore you (and often your party members too ;)
276MCHARM = add_spell {
277	["name"] = 	"Charm",
278        ["school"] = 	{SCHOOL_MINTRUSION},
279        ["am"] = 	50,
280        ["spell_power"] = 0,
281        ["level"] = 	33,
282        ["mana"] = 	10,
283        ["mana_max"] = 	10,
284        ["fail"] = 	10,
285        ["direction"] = function () if get_level(Ind, MCHARM, 50) >= 13 then return FALSE else return TRUE end end,
286        ["spell"] = 	function(args)
287			--reset previous charm spell first:
288			do_mstopcharm(Ind)
289			--cast charm!
290                        if get_level(Ind, MCHARM, 50) >= 13 then
291                                project_los(Ind, GF_CHARMIGNORE, 10 + get_level(Ind, MCHARM, 150), "focusses")
292                        elseif get_level(Ind, MCHARM, 50) >= 7 then
293                                fire_ball(Ind, GF_CHARMIGNORE, args.dir, 10 + get_level(Ind, MCHARM, 150), 3, "focusses")
294                        else
295                                fire_bolt(Ind, GF_CHARMIGNORE, args.dir, 10 + get_level(Ind, MCHARM, 150), "focusses")
296                        end
297	end,
298	["info"] = 	function()
299--                	return "power "..(10 + get_level(Ind, MCHARM, 150))
300			return ""
301	end,
302        ["desc"] =	{
303        		"Tries to manipulate the mind of a monster to make it ignore you",
304                        "At level 7 it turns into a ball",
305                        "At level 13 it affects all monsters in sight",
306        }
307}
308MSTOPCHARM = add_spell {
309	["name"] = 	"Stop Charm",
310        ["school"] = 	{SCHOOL_MINTRUSION},
311        ["am"] = 	0,
312        ["spell_power"] = 0,
313        ["level"] = 	33,
314        ["mana"] = 	0,
315        ["mana_max"] = 	0,
316        ["fail"] = 	-99,
317        ["direction"] = FALSE,
318        ["spell"] = 	function()
319			do_mstopcharm(Ind)
320	end,
321	["info"] = 	function()
322			return ""
323	end,
324        ["desc"] =	{
325        		"Cancel charming of any monsters",
326        }
327}
328