summaryrefslogtreecommitdiff
path: root/npc/config/traps.txt
blob: 1b43e5cc73f15cf19a1c6a7415fceb7e66e181f8 (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
// TMW2 Scripts
// Author:
//   The Mana World Brazil
//   Jesusalva
// Description:
//   Traps and other functions.

// SteelTrap( {damage=80%}, {delay=15s}, {stun=3s}, {npcname=auto} )
function	script	SteelTrap	{
    .@dmg=getarg(0, 80);
    .@delay=getarg(1, 15);
    .@stun=getarg(2, 3);
    .@n$=getarg(3, strnpcinfo(0));

    // It was disarmed
    if (getnpctimer(0) == 0)
    {
        initnpctimer;
        setnpcdisplay .@n$, NPC_TRAP_ONLINE;
        return;
    }

    // Fire!!
    setnpctimer 9000;
    setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;

    // Boom - Hurt players and/or stun monsters
    // This means you can - and SHOULD - lead Forains into these traps
    if (playerattached())
    {
        percentheal -(.@dmg), 0;
    }
    else
    {
        .@stun*=1000;
        sc_start SC_WALKSPEED,(.@delay*1000),60;
        sc_start SC_STUN,rand(.@stun,.@stun*3),0;
    }

    // A minor special effect and we're done.
    specialeffect 11;
    return;
}


// Unlike SteelTrap, presents same behavior and absolute damage
// IronTrap( {damage=100}, {delay=15s}, {stun=3s}, {npcname=auto} )
function	script	IronTrap	{
    .@dmg=getarg(0, 100);
    .@delay=getarg(1, 15);
    .@stun=getarg(2, 3);
    .@n$=getarg(3, strnpcinfo(0));

    // It was disarmed
    if (getnpctimer(0) == 0 && .@delay)
    {
        initnpctimer;
        setnpcdisplay .@n$, NPC_TRAP_ONLINE;
        return;
    }

    // Fire!!
    setnpctimer 9000;
    setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;

    // Boom - Hurt and Stun (only works on players and mobs)
    .@stun*=1000;
    sc_start SC_STUN, rand2(.@stun,.@stun*3), 0;
    .@gid=(playerattached() ? playerattached() : mobattached());

    // Just to be sure
    if (.@gid)
        harm(.@gid, .@dmg, HARM_MISC);
    else
        Exception("IronTrap \""+.@n$+"\" called without GID!", RB_DEBUGMES);

    // A minor special effect and we're done.
    specialeffect 11;
    return;
}