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
|
// 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;
// TODO: Determine duration, power, stun time; use abizit too
// 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;
.@stun =.@ab * 6 / 5; // Up to 12s of stun time (2,4,7,9,12 seconds)
.@n$ = sprintf("sk#_%06d_%06d_%01d_%05d", getcharid(0), .@power, .@stun, htsize($@_DUPES));
getmapxy(.@m$, .@x, .@y, 0);
npc_duplicate("sk#trap", .@n$, .@m$, .@x, .@y);
htput($@_DUPES, .@n$, gettimetick(2) + .@length);
// Get a few mana experience points (this is NOT used by Mana Stone)
GetManaExp(TMW2_TRAPS, rand2(1,.@lv));
return;
}
// Copy from 026-7/config, and htput($@_DUPES, "new_npc_name", expiration_tick)
// Syntax: sk#_CharID_dmg_stun_{uuid}
// 3 + 6 + (up to 6) + 1 = 15 out of 22 chars (5 for UUID)
// So UUID
// We'll also need another trap function
boss,0,0,0 script sk#trap NPC_TRAP,0,0,{
end;
OnTouch:
.@id=getcharid(0);
// FALLTHROUGH
OnTouchNPC:
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
SkillTrap(.@dmg, .@stn);
end;
OnInit:
// A small animation of the trap arming itself...
sleep(500);
setnpcdisplay strnpcinfo(0), NPC_TRAP_ONLINE;
end;
}
|