summaryrefslogtreecommitdiff
path: root/npc/items/rand_mp_heal.txt
blob: 4b6a5ca11720efc2444dd17993d48c26e82e169d (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
// TMW-2 Script.
// Author:
//    Jesusalva
// Description:
//    UGLY WORKAROUND. Legacy Method Only.
// Variables:
//    @min
//    @max
//    @delay

function	script	MPHeal	{
    @delay = getarg(0);
    @min = getarg(1);
    @max = getarg(2);

    if (@delay <= 0) {
        Exception("Invalid healing item, deleting without healing effect.");
        end;
    }

    // +1 max MP per 3 Int, +1 min MP per 5 int.
    // Original max MP will be respected
    @max = min(@max*2, @min+(readparam2(bInt)/5));
    @min = min(@max, @min+(readparam2(bInt)/3));

    // Make these abstract % in absolute values
    @min=max(1, MaxHp*@min/100);
    @max=max(3, MaxHp*@max/100);

    // Save the effect
    @mp_healeffect = rand2(@min, @max);
    @mp_healeffect = @mp_healeffect / @delay + 1;
    @mp_healdelay = @delay;

    // Apply the effect and finish
    deltimer .name$+"::OnUpdate";
    addtimer 1000, .name$+"::OnUpdate";

    // Clear stuff
    // @mp_healeffect and @mp_healdelay must be preserved for cross-reading
    @delay=0;
    @min=0;
    @max=0;
}

-	script	rand_mp_heal	-1,{

OnUse:
    MPHeal(@delay, @min, @max);
    end;

// Script Heart
OnUpdate:
    deltimer .name$+"::OnUpdate";
    heal 0, @mp_healeffect;
    @mp_healdelay-=1;
    if (@mp_healdelay >= 1)
        addtimer 1000, .name$+"::OnUpdate";
    else
        @mp_healeffect=0;
    end;
}