summaryrefslogtreecommitdiff
path: root/npc/008-1/soul-menhir.txt
blob: 3c295c92679535ef48fd422da41320437bdf2af1 (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
// Evol scripts.
// Author:
//    gumi
// Description:
//    place of power, mana refills faster when sitting nearby

008-1,252,111,0	script	Soul Menhir#hurnscald	NPC_NO_SPRITE,{

    end;

OnRefill:
    @menhir_lock = false;
    getmapxy(.@map$, .@x, .@y, UNITTYPE_PC);

    if (.@map$ != .map$ || distance(.x, .y, .@x, .@y) > .refill_distance ||
        !(issit()))
        end;

    heal(0, .refill_rate);
    end;


OnTimer500:
    .@count = getunits(BL_PC, .@units[0], false, .map$, (.x - .refill_distance),
        (.y - .refill_distance), (.x + .refill_distance), (.y + .refill_distance));

    for (.@i = 0; .@i < .@count; ++.@i)
    {
        if (.@units[.@i] < 0) continue; // pre-check, just in case
        deltimer(.name$ + "::OnRefill", .@units[.@i]);
        if (gettimer(TIMER_COUNT, .@units[.@i], .name$ + "::OnRefill") > 0 ||
            getvariableofpc(@menhir_lock, .@units[.@i])) {
            continue;
        }
        set(getvariableofpc(@menhir_lock, .@units[.@i]), true);
        addtimer(rand(.refill_timer), .name$ + "::OnRefill", .@units[.@i]);
    }

    initnpctimer();
    end;

OnInit:

    .refill_rate = 1; // number of SP to give every refill
    .refill_distance = 7; // max distance
    .refill_timer = 200; // wait rand(X) ms before refill
    initnpctimer();

////////// UNFINISHED //////////
////////////////////////////////
// REMOVE THIS CODE WHEN THIS //
// NPC IS NO LONGER A WIP //////
////////////////////////////////
//if (!debug) disablenpc(.name$);
///////// UNFINISHED ///////////

    end;
}