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

// 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);
        if (!(getunitdata(.@mbs[.@i], UDT_MODE) & 32)) { // 32 = MD_BOSS
            //debugmes "Hitting monster (%d hp) for %d damage", .@hp, .@dm;
            setunitdata(.@mbs[.@i], UDT_HP, .@dm);
            specialeffect(FX_ATTACK, AREA, .@mbs[.@i]);
        }
    }
    return;
}

// areasc(range, time, sc, bl) - defaults to 3x3 square, sleep mob for 500ms.
// before was: smoke_grenade(). Valid BL: BL_MOB | BL_PC | BL_HOM | BL_MER
function	script	areasc	{
    .@r=getarg(0, 3);
    .@d=getarg(1, 500);
    .@s=getarg(2, SC_SLEEP);
    .@b=getarg(3, BL_MOB);

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