summaryrefslogtreecommitdiff
path: root/npc/025-1/ihclot.txt
blob: cd093e2b1ac6ee19f621cb7cd3e44538368d9407 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//   Ihclot is Tolchi spelled backwards

025-1,96,66,0	script	Ihclot	NPC_RAIJIN_FEMALE_LEGION_ARTIS,{
    function apRefresh;
    function getPrice;
    function getPriceInt;

    .@left=apRefresh();
    mesn;
    mesq l("I put options on items upon request, but I am very expensive! This is deducted from your tweaking quota.");
    if (!.@left) {
        mesc l("You currently have no Tweaking AP, so you will need to wait %02d minute(s).", 60-gettime(GETTIME_MINUTE)), 1;
        close;
    }
    next;
    mesn;
    mesq l("I'll read the options from you, but the level will be paid by me, and failure rate is non-existant. I am the best. blacksmith. in. the. universe! Use %s if you need to change any options.", b("@ucp"));
    csysGUI_Report();

    mesc l("Please select the item you plan in tweaking."), 1;
    // Request and confirm
    .@id=requestitemindex();
    if (!csys_Confirm(.@id))
        close;

    // Find numeric ID
    delinventorylist();
    getinventorylist();
    .@handle=@inventorylist_id[.@id];
    .@lv=getiteminfo(.@handle, ITEMINFO_ELV);

    // Invalid (absolutely should never happen)
    if (.@handle < 1) {
        mesn;
        mesq l("...What? Which item? Sorry, too much smoke around here.");
        next;
        close;
    }
    // Multiple
    if (countitem(.@handle) != 1) {
        mesn;
        mesq l("Sorry, but you have multiple %s.", getitemlink(.@handle));
        next;
        close;
    }
    // Permission NG: (Not Granted)
    if (.@lv < .minLevel) {
        mesn;
        mesq l("Sorry, but I won't dare touch a %s.", getitemlink(.@handle));
        next;
        mesn;
        mesq l("Depending on the case, Nicholas, in Hurnscald, can do a better job than me.");
        tutmes l("The selected item is too weak. %s will only tweak items level %d or higher.", .name$, .minLevel);
        next;
        close;
    }
    // Aleady slotted
    if (getitemoptionidbyindex(.@id, 0) > 0) {
        mesn;
        mesq l("I'm not going to try to improve this masterpiece. Look its options!");
        next;
        close;
    }

    // Calculate price
    .@price=.@lv**3; // Cubic function to determine price.
    .@price=max(1, .@price/7);
    mesn;
    mesq l("Please select the level I should use.");
    menuint
        l("Abort (%d GP)", fnum(.@price*0)), 0,
        getPrice(.@price, 10), 10,
        getPrice(.@price, 20), 20,
        getPrice(.@price, 30), 30,
        getPrice(.@price, 40), 40,
        getPrice(.@price, 50), 50,
        getPrice(.@price, 60), 60,
        getPrice(.@price, 70), 70,
        getPrice(.@price, 80), 80,
        getPrice(.@price, 90), 90,
        getPrice(.@price, 100), 100;
    mes "";
    if (@menuret == 0)
        close;

    // Ask player to confirm
    if (!csys_Confirm(.@id))
        close;

    // Perform payment
    Zeny-=getPriceInt(.@price, @menuret);
    SMITH_TWEAKS+=1;

    // Apply the bonuses
    csys_ApplyPerfect(.@id, .@level);
    mesn;
    mesc l("Well, here you are. I hope you enjoy ^^", 3);
    // Act 5+ Grace Reroll
    if ($GAME_STORYLINE >= 5) {
        next;
        mesc l("DO YOU WANT TO REROLL THE ITEM? THIS CANNOT BE UNDONE! (free)"), 1;
        next;
        if (askyesno() == ASK_YES)
            csys_ApplyPerfect(.@id, .@level);
    }
    close;

/* *************************************************************************** */
function apRefresh {
    .@left=gettimeparam(GETTIME_HOUR)-SMITH_TWEAKS;
    if (.@left > 6) {
        .@left=6;
        SMITH_TWEAKS=gettimeparam(GETTIME_HOUR)-6;
    }
    return .@left;
}

function getPriceInt {
    .@price=getarg(0);
    .@level=getarg(1);
    .@final=.@price*.@level/5;
    if (strcharinfo(0) == $MOST_HEROIC$)
        .@final=max(1, .@final-(.@level*5000));
    return .@final;
}

function getPrice {
    .@price=getarg(0);
    .@level=getarg(1);
    .@final=getPriceInt(.@price, .@level);
    if (Zeny >= .@final)
        return l("Level %d (%s GP)", .@level, fnum(.@final));
    else
        return "";
}

OnInit:
    .sex = G_OTHER;
    .distance = 5;
    .minLevel = 50;
    end;
}