summaryrefslogtreecommitdiff
path: root/npc/items/grenade.txt
blob: 5768b66cdb17cf4a45b3dd7d18a73d8864e3281a (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
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    Grenades workaround

// Main loop - TODO: Should not affect boss
// grenade(range, damage - in 0.01%, flag) - defaults to 3x3 square, with 5% damage.
// If flag is set, damage will be deemed to be absolute values.
function	script	grenade	{
    .@r=getarg(0, 3);
    .@d=getarg(1, 500);

    getmapxy(.@m$, .@x, .@y, 0);
    .@c=getunits(BL_MOB, .@mbs, false, .@m$, .@x-.@r, .@y-.@r, .@x+.@r, .@y+.@r);
    for (.@i = 0; .@i < .@c; .@i++) {
        .@hp=getunitdata(.@mbs[.@i], UDT_HP);
        .@dm=max(1, .@hp*(10000-.@d)/10000);
        if (getarg(2, false))
            .@dm=max(1, .@hp-.@d);
        //debugmes "Hitting monster (%d hp) for %d damage", .@hp, .@dm;
        setunitdata(.@mbs[.@i], UDT_HP, .@dm);
        specialeffect(FX_ATTACK, AREA, .@mbs[.@i]);
    }
    return;
}
// TODO: Should not affect boss

// smoke_grenade(range, time) - defaults to 3x3 square, stun for 500ms.
function	script	smoke_grenade	{
    .@r=getarg(0, 3);
    .@d=getarg(1, 500);

    getmapxy(.@m$, .@x, .@y, 0);
    .@c=getunits(BL_MOB, .@mbs, false, .@m$, .@x-.@r, .@y-.@r, .@x+.@r, .@y+.@r);
    for (.@i = 0; .@i < .@c; .@i++) {
        sc_start SC_SLEEP, .@d, 1, 10000, SCFLAG_NONE, .@mbs[.@i];
        specialeffect(FX_BUFF, AREA, .@mbs[.@i]);
    }
    return;
}