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
|
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
//
// Magic Script Core Functions
//
// Used for our pseudo-magic.
// These are only helpers, you can add more restrictions and effects freely.
// FIXME
function script abizit {
return 0;
}
// AdjustSpellpower(power=100, {target=@skillTarget{, type=HARM_MAGI}})
function script AdjustSpellpower {
.@power=getarg(0, 100);
.@target=getarg(1, @skillTarget);
.@type=getarg(2, HARM_MAGI);
.@src=getcharid(3);
// Prevents a possible glitch
if (.@target < 1 || .@target == getcharid(3))
.@target=0;
// Calculation FIX
if (.@type == HARM_MAGI) {
.@power+=(readparam2(bInt)/2);
.@dmg=rand2(
getunitdata(getcharid(3), UDT_MATKMIN),
getunitdata(getcharid(3), UDT_MATKMAX));
// Apply defense
if (.@target)
.@dmg=max(0, .@dmg-getunitdata(.@target, UDT_MDEF));
} else if (.@type == HARM_PHYS) {
.@power+=(readparam2(bStr)/2);
.@dmg=rand2(
getunitdata(getcharid(3), UDT_ATKMIN),
getunitdata(getcharid(3), UDT_ATKMAX));
// Apply defense
if (.@target)
.@dmg=max(0, .@dmg-getunitdata(.@target, UDT_DEF));
} else {
.@dmg = .@power; .@power = 100;
}
// Abizit Influence (80%~130% at best, worst shot at perfect ctrl is 105%)
.@dmg = .@dmg * (80 + abizit() * rand2(5,10)) / 100;
.@dmg = .@dmg * .@power / 100;
return .@dmg;
}
// An alias for simplification
// AdjustAttackpower(power=100, {target=@skillTarget{, type=HARM_PHYS}})
function script AdjustAttackpower {
.@power=getarg(0, 100);
.@target=getarg(1, @skillTarget);
.@type=getarg(2, HARM_PHYS);
return AdjustSpellpower(.@power, .@target, .@type);
}
// SkillID, EXP Points
function script GetManaExp {
// FIXME
.@sk=getarg(0);
.@pt=getarg(1);
.@bonus=rand2(0,getskilllv(TMW2_SAGE)*3/2);
if (LAST_SKILL == .@sk) {
.@pt=limit(0, (.@pt+.@bonus)/3, 1);
.@bonus=0;
} else {
// Update skill memory
LAST_SKILL[4]=LAST_SKILL[3];
LAST_SKILL[3]=LAST_SKILL[2];
LAST_SKILL[2]=LAST_SKILL[1];
LAST_SKILL[1]=LAST_SKILL[0];
LAST_SKILL[0]=.@sk;
MAGIC_RP+=1;
// Magic RP is gained by switching skills often
}
// Update Magic EXP
MAGIC_EXP=MAGIC_EXP+.@pt+.@bonus;
return;
}
// SkillID, MobID{, SkillLevelPerMob=2{, Level Override}}
function script SummonMagic {
.@sk=getarg(0);
.@id=getarg(1);
.@adj=getarg(2,2);
.@lv=getarg(3,getskilllv(.@sk));
if (.@adj < 1) {
debugmes "\033[31mInvalid MobPerSkillLevel for SummonMagic (.@adj): "+.@adj+"\033[0m";
dispbottom l("Invalid parameter specified, blame saulc.");
end;
}
// Cause effect
// Summoned monsters live from 45 to 60 seconds, and each skill levels grants 10s extra life
// The 35~50 is not a defect, remember skill starts at level 1...
// PS. Abizit makes a variation from 80% to 130% of official values
for (.@i = 0; .@i < (.@lv+(.@adj-1))/.@adj; .@i++) {
.@lifetime=rand2(35,50)+.@lv*10;
// Abizit makes lifetime vary (like AdjustSpellpower)
.@lifetime = .@lifetime * (80 + abizit() * rand2(5,10)) / 100;
// Unfortunately this version does not returns the summoned monster GID
summon("Summoned Monster", .@id, .@lifetime);
/*
.@mids=summon("Summoned Monster", .@id, .@lifetime);
.@bhp=getunitdata(.@mids, UDT_MAXHP);
// Each skill level raises HP in 5%
.@lvx=.@bhp + max(0, (.@lv-1)*.@bhp/20);
// Abizit makes bonus HP vary (like AdjustSpellpower)
.@lvx = .@lvx * (80 + abizit() * rand2(5,10)) / 100;
setunitdata(.@mids, UDT_MAXHP, .@lvx);
setunitdata(.@mids, UDT_HP, .@lvx);
// Reconfigure monster modes
.@opt=getunitdata(.@mids, UDT_MODE);
// Disable looting
if (.@opt & MD_LOOTER)
.@opt=.@opt^MD_LOOTER;
// All summons can suffer knockback
if (.@opt & MD_NOKNOCKBACK)
.@opt=.@opt^MD_NOKNOCKBACK;
// Strip summons from BOSS mode and immunity
if (.@opt & MD_BOSS)
.@opt=.@opt^MD_BOSS;
// Save new options
setunitdata(.@mids, UDT_MODE, .@opt);
*/
}
dispbottom l("All monsters summoned!");
return;
}
// areaharm(target, range, DMG, {type, element, filter, bl})
// Defaults to HARM_MISC, Ele_Neutral, filter filter_hostile and all BLs
// Valid BL: BL_MOB | BL_PC | BL_HOM | BL_MER
// Do not use: NPC, PET, ELEM
// Range centers on caster (player), implement and use areaharm2 elsewhere
function script areaharm {
.@t=getarg(0);
.@r=getarg(1);
.@d=getarg(2);
.@h=getarg(3, HARM_MISC);
.@e=getarg(4, Ele_Neutral);
.@f$=getarg(5, "filter_hostile");
.@b=getarg(6, BL_PC | BL_MOB | BL_MER | BL_HOM);
getmapxy(.@m$, .@x, .@y, getunittype(.@t), .@t);
.@c=getunits(.@b, .@mbs, false, .@m$, .@x-.@r, .@y-.@r, .@x+.@r, .@y+.@r);
for (.@i = 0; .@i < .@c; .@i++) {
// Filtering
if (!callfunc(.@f$, .@mbs[.@i]))
continue;
harm(.@mbs[.@i], .@d, .@t, .@e);
specialeffect(FX_ATTACK, AREA, .@mbs[.@i]);
// TODO: Handle MobPt to don't overload timer system?
}
return;
}
// rectharm(target, x, y, DMG, {type, element, filter, bl})
// Same as areaharm() but causes a rectangle in (x,y) size, instead of a square
function script rectharm {
.@t=getarg(0);
.@rx=getarg(1);
.@ry=getarg(2);
.@d=getarg(3);
.@h=getarg(4, HARM_MISC);
.@e=getarg(5, Ele_Neutral);
.@f$=getarg(6, "filter_hostile");
.@b=getarg(7, BL_PC | BL_MOB | BL_MER | BL_HOM);
getmapxy(.@m$, .@x, .@y, getunittype(.@t), .@t);
.@c=getunits(.@b, .@mbs, false, .@m$, .@x-.@rx, .@y-.@ry, .@x+.@rx, .@y+.@ry);
for (.@i = 0; .@i < .@c; .@i++) {
// Filtering
if (!callfunc(.@f$, .@mbs[.@i]))
continue;
harm(.@mbs[.@i], .@d, .@t, .@e);
specialeffect(FX_ATTACK, AREA, .@mbs[.@i]);
// TODO: Handle MobPt to don't overload timer system?
}
return;
}
// mescordialog(text, color, {dialog=1})
function script mescordialog {
if (getarg(2, true))
mesc getarg(0), getarg(1);
else
dispbottom col(getarg(0), getarg(1));
return;
}
// ShowAbizit({dialog=1})
function script ShowAbizit {
.@dial=getarg(0, true);
if (.@dial)
mesn l("Current Magic Control");
// FIXME
.@val=MAGIC_EXP+rand(-MAGIC_LVL*5, MAGIC_LVL*5);
.@base=((MAGIC_LVL*2)**3);
if (.@val > .@base*5)
mescordialog l("You are perfectly in control of your magic."), 3, .@dial;
else if (.@val > .@base*4)
mescordialog l("You are mostly in control of your magic."), 2, .@dial;
else if (.@val > .@base*3)
mescordialog l("You are somewhat in control of your magic."), 4, .@dial;
else if (.@val > .@base*2)
mescordialog l("Your magic is more powerful than you, but you can control."), 7, .@dial;
else if (.@val > .@base)
mescordialog l("You still are overwhelmed by your magic."), 6, .@dial;
else
mescordialog l("You are completly overwhelmed by your magic."), 1, .@dial;
return;
}
// SK_summon(ID, amount, mexp)
function script SK_summon {
.@mob=getarg(0);
.@amt=getarg(1);
.@mex=getarg(2);
if ($@GM_OVERRIDE || debug) debugmes "Skill "+@skillId+" Lv "+@skillLv;
if (rand2(5) < abizit()) {
// Summon Magic (with magic level bonus)
SummonMagic(@skillId, .@mob, .@amt, MAGIC_LVL+@skillLv-1, @skillLv);
} else if (rand2(5) < abizit()) {
// Re-roll
dispbottom l("You cannot complete the casting correctly!");
SummonMagic(@skillId, .@mob, 1, 1, 1);
} else if (abizit() <= 1 && any(true, false, false)) {
// Spell overwhelms you, causing it to be spawned as aggro vs you. (33%)
dispbottom l("The spell takes a mind of its own backfires!");
getmapxy(.@m$, .@x, .@y, 0);
.@opo=monster(.@m$, .@x, .@y, "Failed summon", .@mob, 1);
unitattack(.@opo, getcharid(3));
} else {
dispbottom l("The spell fails!");
}
// Get a single mana experience point (FIXME)
GetManaExp(@skillId, .@mex);
return;
}
- script Magic Load NPC_HIDDEN,{
OnInit:
end;
OnSkillInvoke:
end;
OnPCBonusEvent:
end;
}
|