summaryrefslogtreecommitdiff
path: root/npc/functions/TODO.txt
blob: 8060fe579e358ba7dc5b8ca881d21d0ac890cfd8 (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
// TMW2/LoF Script
// Author:
//  Jesusalva
// Description:
//  ToDo - Please disregard for now

// Important variables:
//  MERC_EXP
//      Experience on Thief Tree
//  MERC_RANK
//      Position on the Thief Tree

// ToDoMerc(num_pins, max_pins)
// Returns 0 upon failure, 1 upon success
// Closes script if an error happen or if you give up / cannot try.
//
// The 'next' is upon script responsability
// Maximum pin number is infinite. Maximum Pin Positiors range from 2~5.
// If you fail, you can end up having to start again. If you fail too much,
// you'll be caught!
function	script	ToDoMerc	{
    // If you don't have a LockPick, you can't do this (useless)
    if (!countitem(Lockpicks)) {
        mesc l("You need a @@ to try this.", getitemlink(Lockpicks)), 1;
        close;
    }

    .@d=getarg(0,1);
    .@m=getarg(1,3);

    // Invalid Argument (kill script)
    if (.@d < 1 || .@m < 2 || .@m > 5)
        end;

    // You must be rank (number of locks - 1) to try
    if (MERC_RANK+1 < .@d) {
        mesc l("This lock is beyond your current capacity."), 1;
        close;
    }

    // Create @pins array (the answer)
    for (.@i=0; .@i < .@d;.@i++)
        @pins[.@i] = rand(1,.@m);

    // Check if you'll try to open it.
    mesc l("I'm not sure exactly what we are trying to do, but you seem to need to resolve this puzzle.");
    mesc l("Will you try to unlock it?");
    if (askyesno() == ASK_NO)
        close;

    // Setup your attempt
    delitem Lockpicks, 1;
    @pos=0;
    mesc l("There are only @@ pins to set.", .@d);

    // You have as many attempts as pins and appliable strenghts.
    // Each merc rank grants you an extra attempt.
    // Each pin takes one attempt.
    // It's not multiplied, so 3 pins with 3 positions: 6 chances, 9 possibilities.
    // There's no penalty, but the attempt is counted working or not!
    // Remember if you fail, all previous pins will be cleared (@pos)
    for (.@i=0; .@i < (.@d+.@m+MERC_RANK) ; .@i++) {
        mesc l("You are trying to lock the @@th pin. What will to do?", @pos+1);

        menuint
            rif(.@m >= 4, l("Apply no pressure")), 4,
            rif(.@m >= 2, l("Apply soft pressure")), 2,
            rif(.@m >= 1, l("Apply normal pressure")), 1,
            rif(.@m >= 3, l("Apply strong pressure")), 3,
            rif(.@m >= 5, l("Apply very strong pressure")), 5,
            l("Give up!"), 0;

        if (!@menuret)
            close;

        // Is your guess correct?
        if (@pins[@pos] == @menuret) {
            mesc l("*click*");
            @pos+=1;
        } else {
            mesc l("This didn't work. All pins are now unlocked!");
            @pos=0;
            // We don't need to clear console, each successful attempt IS counted.
            // Therefore, unsetting 3 pins means you must do 3 new attempts!!
            // The biggie is that you're running against time, here!!!
        }

        if (@pos >= .@d) {
            MERC_EXP += .@d*.@m-MERC_RANK;
            return 1;
        }
    }

    MERC_EXP += 1;
    return 0;
}