blob: 0ba40bc82a5ea29708dffbe696e4c9739fb214d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
"Default sfx on caster"
(PROCEDURE default_effect ()
(sfx caster
(+
(- school MAGIC)
2)
0))
(PROCEDURE sfx_generic (target)
(sfx target SFX_DEFAULT 0))
(PROCEDURE sfx_lightning (target)
(sfx target SFX_LIGHTNING 0))
(PROCEDURE set_var (name mask shift value)
(set_script_variable caster name
(|
(&
(script_int caster name)
(neg
(<< mask shift)))
(<<
(& value mask)
shift))))
"value is How many HP we healed"
"gain is how many life magic experience points we can potentially gain"
"heal_xp_value_divisor is 1 for instaheal, 2 for slow heal"
"base_exp_factor is the factor for how many base experience points (max) the player should be allowed to gain"
(PROCEDURE gain_heal_xp (value gain heal_xp_value_divisor base_exp_factor)
(SET last_heal_xp
(&
(>>
(script_int caster SCRIPT_XP)
SCRIPT_HEALSPELL_SHIFT)
SCRIPT_HEALSPELL_MASK))
(IF (&&
(!= target caster)
(>
(/ value heal_xp_value_divisor)
(+
(+
(+ 10 last_heal_xp)
(random
(+ last_heal_xp 1)))
(random
(+ last_heal_xp 1)))))
(BLOCK
(SET heal_xp
(+ last_heal_xp gain))
(IF (> heal_xp SCRIPT_HEALSPELL_MASK)
(SET heal_xp SCRIPT_HEALSPELL_MASK))
(CALL set_var SCRIPT_XP SCRIPT_HEALSPELL_MASK SCRIPT_HEALSPELL_SHIFT heal_xp)))
(IF (!= target caster)
(gain_experience caster
(* base_exp_factor
(extract_healer_experience target value))
0
1)))
(PROCEDURE gain_xp (gain index)
"Level 4 and 5 magic users don't gain anything from spell levels 0 resp. 0+1"
(IF (>
(+ level 3)
(skill caster MAGIC))
(BLOCK
(SET last_index
(&
(>>
(script_int caster SCRIPT_XP)
SCRIPT_LASTSPELL_SHIFT)
SCRIPT_LASTSPELL_MASK))
(SET last_xp
(&
(>>
(script_int caster SCRIPT_XP)
SCRIPT_XP_SHIFT)
SCRIPT_XP_MASK))
(IF (!= index last_index)
(BLOCK "Some variation observed"
(SET xp
(+ last_xp gain))
(IF (> xp SCRIPT_XP_MASK)
(SET xp SCRIPT_XP_MASK))
(CALL set_var SCRIPT_XP SCRIPT_XP_MASK SCRIPT_XP_SHIFT xp)
(CALL set_var SCRIPT_XP SCRIPT_LASTSPELL_MASK SCRIPT_LASTSPELL_SHIFT index)
(IF DEBUG
(message caster
(+ "Spell xp = " xp))))
(IF DEBUG
(message caster
(+ "Re-cast same spell, xp remain at " last_xp)))))))
(PROCEDURE create_item (good_item count bad_item difficulty)
(SET success 1)
(SET score
(+ experience
(random
(min spellpower
(+
(/ experience 3)
1)))))
(IF (>= score difficulty)
(create_item caster good_item count)
(BLOCK
(SET success 0)
(SET score
(+
(+ score
(random
(luk caster)))
(random
(luk caster))))
(IF (< score
(/ difficulty 3))
(BLOCK
(message caster "Your spell backfires!")
(IF (<
(random 110)
(luk caster))
(itemheal caster
(- 0
(*
(*
(+ level 1)
(+ level 2))
(+ 3
(random 28))))
0)
(itemheal caster
(- 0
(+ level 1))
0)))
(IF (< score
(/
(* difficulty 2)
3))
(BLOCK
(IF (==
(random 5)
0)
(BLOCK
(message caster "Your spell solidifies into the shape of a mysterious object!")
(create_item caster "Iten" 1))
(message caster "Your spell escapes!")))
(BLOCK
(message caster "Your spell takes on a mind of its own!")
(IF (==
(random 3)
0)
(create_item caster bad_item 1))))))))
"Increase spellpower by school and general magic skill"
(PROCEDURE adjust_spellpower (school)
(SET experience
(&
(>>
(script_int caster SCRIPT_XP)
SCRIPT_XP_SHIFT)
SCRIPT_XP_MASK))
(SET spellpower
(+ spellpower
(*
(+
(skill caster MAGIC)
(skill caster school))
10)))
"Below, we adjust by special items"
(IF (&&
(not
(failed target))
(||
(== school LIFE)
(== school NATURE)))
(IF target
(IF (==
(pc target)
(partner caster))
(BLOCK
(SET spellpower
(+ spellpower 200))
(IF (is_equipped caster "WeddingRing")
(SET spellpower
(+ spellpower 50)))
(IF (is_equipped
(pc target)
"WeddingRing")
(SET spellpower
(+ spellpower 50))))))))
(PROCEDURE heal (target max_heal)
(CALL default_effect)
(IF (!= caster target)
(sfx target SFX_HEAL 0))
(SET power
(+ spellpower
(vit caster)))
(SET power
(min max_heal
(/
(* max_heal power)
250)))
(itemheal target power 0))
"Goes through instaheal instead of itemheal"
(PROCEDURE quickheal (target power)
(CALL default_effect)
(IF (!= caster target)
(sfx target SFX_HEAL 0))
(instaheal target power 0))
"Can attack the target? Imports attack_range from dynamic environment"
(PROCEDURE attack_check (target)
(IF (not
(line_of_sight
(location caster)
(location target)))
(ABORT))
(IF (not
(<=
(rdistance
(location caster)
(location target))
attack_range))
(ABORT)))
"Cause elemental damage. bonus_elt grants an attack bonus, malus_elt reduces the attack. `effect' is the sfx ID."
(PROCEDURE elt_damage (target damage dmgplus bonus_elt malus_elt effect)
(SET d
(+ damage
(random dmgplus)))
(IF (==
(element target)
malus_elt)
(SET d
(/ d 3)))
(IF (==
(element target)
bonus_elt)
(SET d
(/
(* d
(+ 4
(element_level target)))
4)))
(sfx target effect 0)
(injure caster target d 0))
(PROCEDURE melee_damage (target damage dmgplus)
(CALL attack_check target)
(SET d
(+ damage
(random dmgplus)))
(SET evade
(+
(level target)
(mdef target)))
(IF (<
(- spellpower
(random 100))
evade)
(SET d 0))
(injure caster target d 0))
(PROCEDURE install_attack_spell (charges base_delay range attack_animation)
(CALL default_effect)
(SET attack_range range)
(override_attack caster charges
(/
(*
(- 200
(agi caster))
base_delay)
200)
range
ATTACK_ICON_GENERIC
attack_animation
0))
(PROCEDURE install_melee_spell (charges base_delay attack_animation)
(CALL install_attack_spell charges base_delay 1 attack_animation))
(PROCEDURE summon_spell (mob_id count delay lifetime control_level school)
(CALL default_effect)
(sfx location SFX_SUMMON_START 0)
(WAIT delay)
(sfx location SFX_SUMMON_FIRE 0)
(spawn
(rbox location 2)
caster
mob_id
(if_then_else
(>=
(skill caster school)
control_level)
2
1)
count
lifetime)) "pets when level is high enough"
(PROCEDURE abort_on_area_shield (pos)
(IF (&&
(==
(is_exterior pos)
1)
(||
(||
(==
(map_nr pos)
1)
(==
(map_nr pos)
9))
(==
(map_nr pos)
20)))
(BLOCK "1 is Tulimshar, 9 is Hurnscald and 20 is Nivalis"
(message caster "A powerful magic drains your spell just as it is beginning to take shape!")
(ABORT))))
(PROCEDURE script_split_str (d str v m)
(FOR a 0 m
(BLOCK
(IF (< (strlen str) 1) (BREAK))
(SET arglen (strlen str))
(SET argoffset
(if_then_else
(contains_string str d)
(strstr str d)
arglen))
(SET arg
(if_then_else (== arglen argoffset)
str
(substr str 0 argoffset)))
(set_script_str caster (+ (+ "@" v) (+ a "$")) arg)
(SET str
(if_then_else
(> arglen (- argoffset 1))
(substr str (+ argoffset 1) arglen)
"")))))
|