summaryrefslogtreecommitdiff
path: root/npc/items/alcohol.txt
blob: 6ecad55714466eddd4648d10beddf6c3e16cd5a7 (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
// TMW-2 Script.
// Author:
//    Crush
//    Jesusalva
// Description:
//    Alcohol effects
//    TODO: Retroactive, weakens every hour...
//
// Variables:
//    @taste    Alcohol taste (0~100) - influences exp up
//    @Alcool   Alcoholic rating (0~100) - influences Attack Speed Malus, Min. Vit and duration
//    ALC_DELAYTIME For how long you are drunk (the delay) - gettimetick(2)
//    ALC_THRESHOLD How drunk you are (the bonus)
//
//    When drunk, attack speed is lowered but exp gain is increased.
//    Attack Speed Reductor: SC_ATTHASTE_INFINITY
//    Max HP Reductor: SC_INCMHPRATE
//    EXP Increaser: SC_OVERLAPEXPUP

-	script	alcohol_sc	-1,{

    // Stack remaning bonuses if the last one hasn't finished
    // remaining_bonuses(sc, type)
    // type 0: delay
    // type 1: value
    function remaining_bonus
    {
        if (getstatus(getarg(0)))
        {
            if (getarg(1))
                return getstatus(getarg(0), 1);
            else
                return getstatus(getarg(0), 4); // Shouldn't it be 5? 
        }
        return 0;
    }

OnUse:
    if (@Alcool <= 0) close;
    // Do you have enough vitality to hold your beer?
    .@vit=readparam(bVit);
    if (@Alcool+ALC_THRESHOLD > .@vit) {
        dispbottom l("You vomit, you are too drunk for this to have effect anymore.");
        dispbottom l("Raise vitality to be able to drink even more.");
		sc_start SC_CONFUSION, 5000, 0, 10000, SCFLAG_NOAVOID; // Warning, forces user to use @resync!
        end;
    }

    // Put the delay in ms. Each ALCOOL point is 10 minutes.
    .@delay = remaining_bonus(SC_OVERLAPEXPUP, false);
    .@delay += @Alcool*600*1000;
    // Alcohol EXP Bonus sums to previous exp bonus
    .@val1 = remaining_bonus(SC_OVERLAPEXPUP, true);
    .@val1 += @taste;

    // Reset EXP Bonus
    sc_end SC_OVERLAPEXPUP;
    sc_start SC_OVERLAPEXPUP, .@delay, .@val1;

    // Same goes for attack speed debuff
    // Except delay does not stack, and malus is recalculated
    .@delay = @Alcool*600*1000;
    .@val1 = ALC_THRESHOLD+@Alcool;

    // Reset Attack Speed Debuff
    sc_end SC_ATTHASTE_INFINITY;
    sc_start SC_ATTHASTE_INFINITY, .@delay, -.@val1;

    // Recalculate Alcohol Threshold and time
    ALC_THRESHOLD+=@Alcool;
    if (ALC_DELAYTIME < gettimetick(2))
        ALC_DELAYTIME=gettimetick(2);
    ALC_DELAYTIME+=@Alcool*600*1000;
    close;
}