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
|
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
//
// Magic Script: TMW2_TRAPS
//
// Deploy a trap behind you.
function script SK_Traps {
.@lv = getskilllv(TMW2_TRAPS);
.@ab = abizit() * 2;
// More abizit: Longer duration and stun time
// Higher level: Longer duration and power
.@length=40 + (.@lv+.@ab)*4; // Max duration: 120 seconds
.@power =.@lv * (100+(REBIRTH*20)+(BaseLevel/2));
.@stun =(1+abizit()) * 9 / 6; // Up to 9s of stun time (1,3,4,6,7,9 seconds)
// Sanitization
.@power = min(99999, .@power);
.@n$ = sprintf("#sk_%06d_%d_%01d_%03d", getcharid(0), .@power, .@stun, htsize($@_DUPES));
getmapxy(.@m$, .@x, .@y, 0);
//npc_duplicate("sk#trap", .@n$, .@m$, .@x, .@y);
npc_duplicate("sk#trap", .@n$, .@m$, .@x, .@y, NPC_TRAP, 0, 0, 0);
htput($@_DUPES, .@n$, gettimetick(2) + .@length);
set(getvariableofnpc(.capacity, .@n$), .@length);
// Get a few mana experience points (this is NOT used by Mana Stone)
GetManaExp(TMW2_TRAPS, rand2(1,.@lv));
return;
}
// Syntax: #sk_CharID_dmg_stun_{uuid}
// 4+ 3 + 6 + (up to 5) + 1 = 19 out of 22 chars (3 for UUID)
boss,0,0,0 script sk#trap NPC_TRAP,0,0,{
end;
OnTouch:
// Do not affect players outside PVP
if (!ispvpmap())
end;
// Collect player ID to compare with caster
.@id=getcharid(0);
// FALLTHROUGH
OnTouchNPC:
// Capacity exausthed, disable the trap
if (.capacity <= 0) {
setnpcdisplay strnpcinfo(0), NPC_TRAP;
.@t = htget($@_DUPES, .name$, 0);
if (.@t) {
.@t = min(gettimetick(2)+2, .@t);
htput($@_DUPES, .name$, .@t);
}
end;
}
// Retrieve parameters
explode(.@parts$, strnpcinfo(0), "_");
.@gid=atoi(.@parts$[1]);
.@dmg=atoi(.@parts$[2]);
.@stn=atoi(.@parts$[3]);
// Do not harm the trap setter/caster
if (.@id == .@gid)
end;
// Actual trap function
.capacity -= 1;
SkillTrap(.@dmg, .@stn);
end;
OnInit:
.capacity = INT_MAX;
// A small animation of the trap arming itself...
sleep(500);
setnpcdisplay strnpcinfo(0), NPC_TRAP_ONLINE;
end;
}
|