summaryrefslogtreecommitdiff
path: root/npc/functions/refine.txt
blob: 65f88e092c46e7a954bbc7fc79680111c56d73d7 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// TMW2 Script
// Author:
//      Jesusalva
// Description:
//      Refine functions

// (No arguments)
function	script	refineMaster	{
    mesn;
    mesq l("Ah, hello there, funny face! Do you want to refine items?");
    mesc l("There's always some chance that THE ITEM WILL BREAK, beware!");
    next;
    mesn;
    mesq l("First - item must be equipped.");
    mesq l("If you succeed, the defense and/or attack will raise. If you fail, refine level goes down.");
    //mesq l("And if the item breaks, that is definitive - no repair is possible. What to refine?");
    mesq l("And if the item breaks, that's your loss. What to refine?");
    next;

    // Dark magic from hercules used, take care
    menuint
        l("Nothing, thanks"), 0,
        rif(getequipisequiped(EQI_ARMOR), l("My chestplate, @@", getequipname(EQI_ARMOR))), EQI_ARMOR,
        rif(getequipisequiped(EQI_HAND_R), l("My weapon, @@", getequipname(EQI_HAND_R))), EQI_HAND_R,
        l("Definitive item break? Too dangerous! I don't want it!!"), 0;


	if (@menuret == 0) {
        mesn;
        //mesq l("Wait a moment - you are naked! YOU WILL DIE IN THE FREEZE! o.o");
        mesq l("Well... we'll see around!");
		close;
	}
    .@it=@menuret;
    .@item=getequipid(.@it);

    /*
    mes "##B" + l("Drag and drop an item from your inventory.") + "##b";
    .@item = requestitem();

    // Check if we received an item
    if (.@item < 1) {
        mesn;
        mesq l("Well, no risk, no gain.");
        close;
        return;
    }
    */

    // Not all items are refinable
	if (!getequipisenableref(.@item)) {
		mesn;
		mesq l("Well, sorry, but only weapons and body armor can be refined.");
        mesq l("There may be some exceptions. Anyway, this item clearly cannot be refined.");
		return;
	}

    // Max refining level: 10
	if (getequiprefinerycnt(.@it) >= 10) {
		mesn;
		mesq l("This item cannot be refined further.");
        return;
	}

    .@rlv=getequiprefinerycnt(.@it);
    .@price=(.@rlv+1)*1000;
    .@amount=(.@rlv/2)+1;
    // required item
    switch (.@rlv) {
        case 0:
        case 1:
        case 2:
            .@rg=IronIngot; break;
        case 3:
        case 4:
            .@rg=TitaniumIngot; break;
        case 5:
        case 6:
            .@rg=LeadIngot; break;
        case 7:
        case 8:
            .@rg=Bloodstone; break;
        default:
            .@rg=BlueManaPearl; break;
    }
    mesn;
    mesq l("This @@ is a nice stuff. I can refine it for @@ GP and @@ @@.", getitemlink(.@item), .@price, .@amount, getitemlink(.@rg));
    mesc l("Success ratio is of aprox. @@ %%" % (100-(.@rlv*10)));
    next;
    if (askyesno() != ASK_YES)
        close;

    // Anti-Crazyfefe™ System
    // Item is gone, 100% warranted cheater
    if (countitem(.@item) < 1) {
        mesn;
        mesc l("All cheaters must die."), 1;
        percentheal -100, -100;
        close;
    }
    // No money
    if (Zeny < .@price) {
        mesn;
        mesq l("Where's the money? Go away.");
        close;
    }
    // No reagents
    if (countitem(.@rg) < .@amount) {
        mesn;
        mesq l("Where's the reagent? You don't expect me to find it, right? Go bring them!");
        close;
    }
    // Item removed
	if (getequipisequiped(.@it) == 0) {
        mesn;
        mesc l("All cheaters must die."), 1;
        percentheal -100, -100;
        close;
    }
    // Item changed
	if (getequiprefinerycnt(.@it) != .@rlv || getequipid(.@it) != .@item) {
        mesn;
        mesc l("All cheaters must die."), 1;
        percentheal -100, -100;
        close;
    }
    ///// This should cover most of Crazyfefe tricks ¬.¬ I hope ¬.¬
    mesn;
    mesq l("HA, HA, HA! The blacksmiths from the Land of Fire are the best from the world! There's no challenge too big for us!");
    mesq l("It's time to show this shiny @@ who is the boss! HAHAHAHAHAHAHAH!", getitemlink(.@item));
    next;
    // If you cheat somewhere along the way, the script will explode
    Zeny=Zeny-.@price;
    delitem .@rg, .@amount;
    // Cheater should be locked for eternity.
	if (getequiprefinerycnt(.@it) != .@rlv || getequipid(.@it) != .@item || getequipisequiped(.@it) == 0) {
        atcommand "@jail "+strcharinfo(0);
        close;
    }

    // Were we successful?
	if (getequippercentrefinery(.@it) > rand(100)) {
	    successrefitem .@it;
        mesn;
        mesq l("HAHAHAHAH! Shiny as new, and stronger than ever! Have fun!");
        next;
    // Perhaps the item has broken?
    } else if (rand(100) < .@rvl*2) {
		failedrefitem .@it;
        mesc l("*CRASH*");
        next;
        mesn;
        mesq l("Ops... I hammered this stuff too hard... It's junk now.");
        next;
        mesn;
        mesq l("Well, you were warned. Do you have any other stuff for me?");
        next;
    // Item is weakened.
    } else {
		downrefitem .@it, 1;
        mesn;
        mesq l("A masterpiece!... Whaaaat, this stuff got ##Bweaker##b??");
        next;
        mesn;
        mesq l("Well, I did my best, but this had been so refined, that it was difficult to find my way.");
        next;
        mesn;
        mesq l("I'm sure I could refine this again, if you bring me the payment and the reagents again.");
        next;
    }
    return;
}