summaryrefslogtreecommitdiff
path: root/npc/items/rand_sc_heal.txt
blob: 41ea3b3a73534e55995adc44ee4dc909bd7c127b (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// TMW-2 Script.
// Evol scripts.
// Author:
//    Reid
//    Jesusalva
// Description:
//    Random heal every x seconds.
//
// Variables:
//    @type
//          0 - Sweeties (lowest)
//          1 - Vegetables
//          2 - Proteins
//          3 - Proccessed
//          4 - Magical (highest)
//   @delay
//      Overrides the lasting time
//   @rarity
//      How rare the item is (how much should it effect)
//      Ranges from 1 to 10.
//
//  Formula:
//      MinHeal %: @rarity * ((@type*1) + 1)
//      MaxHeal %: @rarity * ((@type*2) + 1)
//      Delay: 1 + (@type*2)
//          Sweeties: 1s
//          Vegetables: 3s
//          Proteins: 5s
//          Proccessed: 7s
//          Magical: 9s
//
// *getequipoption(EQI_HEAD_TOP,1,168); → Heal Bonus (should be first bonus on Chef Hat)

// ItHeal(type, rarity{, delay=auto})
function	script	ItHeal2	{
    .@type=getarg(0);
    .@rarity=getarg(1);
    .@delay=getarg(2, 0);

    // Calculate healing value in %
    .@min=.@rarity * ((.@type*1) + 1);
    .@max=.@rarity * ((.@type*2) + 1);

    // Healing items always have a bonus positive variation as you are reborn
    .@max+=REBIRTH;

    // Vitality raises the minimum healing value in 1%, capped at maximum vlaue
    // It also raises @max up to double
    .@max = min(.@max*2, .@max+(readparam2(bVit)/50));
    .@min = min(.@max, .@min+(readparam2(bVit)/30));

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

    // Calculate how much you'll heal
    @val1 = rand2(.@min, .@max);

    // Calculate delay if it was not given
    if (.@delay <= 0) {
        .@delay=1 + ((.@type*3)/2);
    }

    // Update val1
    @val1 = (@val1 / .@delay) + 1;

    // Decide the healing bonus type. We have four types: S, L, G and M
    // By default, we use 'S'
    .@skill = SC_S_LIFEPOTION;

    // We now have @val1 (new effect), @delay (new delay)
    // But do we have .@v and .@d (old effect and delay)?
    //Meh, just override it
    /*
    if (getstatus(.@skill)) {
        .@v=getstatus(.@skill, 1);
        .@d=getstatus(.@skill, 5);
    }

    // If there WAS an effect previously, get ponderate average
    if (.@v > 0) {
        @val1=ponderate_avg(@val1, @delay, .@v, .@d);
        @delay=ponderate_avg(@delay, @val1, .@d, .@v);
    }
    */

    // Put the delay in ms
    .@delay *= 1000;

    // Apply the effect and finish
    sc_end .@skill;
    sc_start2 .@skill, .@delay, @val1, 1;
    return @val1;
}

-	script	rand_sc_heal	-1,{
    end;
OnUse:
    if (@rarity <= 0) {
        Exception("Invalid healing item, deleting without healing effect.");
        end;
    }
    ItHeal2(@type, @rarity, @delay);

    // Clear stuff
    // @val1 must be preserved for cross-reading
    @delay=0;
    @type=0;
    @rarity=0;
    // @val1=0;
    end;
}