summaryrefslogtreecommitdiff
path: root/npc/custom/eAAC_Scripts/kafraExpress/ke_uncard.txt
blob: 4ff5b7c8b62a58669635f03eb5435c470bdcf637 (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
//===== eAthena Script ======================================= 
//= Kafra Express - Uncarder Module
//===== By: ================================================== 
//= Skotlex 
//===== Current Version: ===================================== 
//= 1.5
//===== Compatible With: ===================================== 
//= eAthena SVN R3424+
//===== Description: ========================================= 
//= Part of the Kafra Express Script Package.
//= Offers uncarding services.
//===== Additional Comments: ================================= 
//= See config.txt for configuration.
//============================================================ 

-	script	keInit_uncard	-1,{
OnInit:	//Load Config
	donpcevent "keConfig::OnLoadUncard";
	end;
}

function	script	F_keUncard	{

function SF_uncard;

	do {
		set @kmenu, select(
			"- Return",
			"- See Price Specifics",
			"- "+getequipname(1),
			"- "+getequipname(2),
			"- "+getequipname(3),
			"- "+getequipname(4),
			"- "+getequipname(5),
			"- "+getequipname(6),
			"- "+getequipname(7),
			"- "+getequipname(8),
			"- "+getequipname(9),
			"- "+getequipname(10)
		);
		if (@kmenu == 1)
			return;
		if (@kmenu == 2) {	//Details
			mes "Okay, listen up...";
			next;
			mes "["+@name$+"]";
			if ($@keuc_BaseCost)
				mes "The base cost is of "+$@keuc_BaseCost+"z.";
			mes "Each card to be removed incurs a cost of +"+$@keuc_CardCost+"z.";
			mes "The refine level of the compounded equipment can incur an additional cost:";
			mes "Armors: "+$@keuc_UpgradeCostA+"z per level.";
			mes "Lv1 Weapons: "+$@keuc_UpgradeCostW1+"z per level.";
			mes "Lv2 Weapons: "+$@keuc_UpgradeCostW2+"z per level.";
			mes "Lv3 Weapons: "+$@keuc_UpgradeCostW3+"z per level.";
			mes "Lv4 Weapons: "+$@keuc_UpgradeCostW4+"z per level.";

			if ($@keuc_Mat1 && $@keuc_Qty1) {
				mes "The materials needed are:";
				mes "- "+$@keuc_Qty1+" "+getitemname($@keuc_Mat1)+".";
			}
			if ($@keuc_Mat2 && $@keuc_Qty2)
				mes "- "+$@keuc_Qty2+" "+getitemname($@keuc_Mat2)+".";
			
			if ($@keuc_Fail1Chance || $@keuc_Fail2Chance)
				mes "There is a chance the process might fail and you'll lose your items.";

			next;
			callfunc "F_keIntro", -1, "";
		} else {
			if (SF_uncard(@kmenu-2))
				return;
		}
	} while (@kmenu >1);
	return;

//Subfunction SF_uncard (equipment-position)
//Attempts to uncard the equipment.
function SF_uncard {
	set @part, getarg(0);
	if(getequipcardcnt(@part) == 0) {
		callfunc "F_keIntro", e_ag, "There are no cards to remove there!";
		return 0;
	} 
	set @cost, $@keuc_BaseCost;
	set @cost, @cost + $@keuc_CardCost*getequipcardcnt(@part);

	switch (getequipweaponlv(@part)) {
	case 0: //Armor
		set @upgradeCost, $@keuc_UpgradeCostA;
		break;
	case 1: //Lv1 Weapons
		set @upgradeCost, $@keuc_UpgradeCostW1;
		break;
	case 2: //Lv2 Weapons
		set @upgradeCost, $@keuc_UpgradeCostW2;
		break;
	case 3: //Lv3 Weapons
		set @upgradeCost, $@keuc_UpgradeCostW3;
		break;
	default: //Lv4 Weapons
		set @upgradeCost, $@keuc_UpgradeCostW4;
	}
	
	set @cost, @cost + @upgradeCost*getequiprefinerycnt(@part);

	set @price, callfunc("F_keCost",@cost,$@keuc_discount);
	
	if ($@keuc_Fail1Chance) {
		set @failsave, select(
			"- Cancel",
			"- Remove cards ("+@price+"z, item gets priority)",
			"- Remove cards ("+@price+"z, cards get priority)"
		);
	} else {
		set @failsave, select(
			"- Cancel",
			"- Remove cards ("+@price+"z)"
		);
	}
	if (@failsave == 1)
		return 0;
	set @failsave, @failsave-1;	//1: Save item, 2: Save Card

	if (($@keuc_Mat1 && countitem($@keuc_Mat1) < $@keuc_Qty1)
		|| ($@keuc_Mat2 && countitem($@keuc_Mat2) < $@keuc_Qty2)) {
		callfunc "F_keIntro", e_pif, "You do not have all the materials I need...";
		return 0;
	}
	
	if (!(callfunc("F_keCharge",@cost,$@keuc_discount,1))) {
		callfunc "F_keIntro", e_ag, "Sorry, you don't have enough zeny.";
		return 0;
	}
	
	if ($@keuc_Mat1 && $@keuc_Qty1)
		delitem $@keuc_Mat1, $@keuc_Qty1;
	if ($@keuc_Mat2 && $@keuc_Qty2)
		delitem $@keuc_Mat2, $@keuc_Qty2;
	
	set @failtype,-1;
	//Recycling cost...
	set @cost, rand(1000);
	if (@cost < $@keuc_Fail2Chance)	//Total Failure
		set @failtype, 0;
	else if (@cost < $@keuc_Fail1Chance)	//Partial Failure
		set @failtype, @failsave;
	else if (@cost < $@keuc_Fail0Chance)	//Harmless Failure
		set @failtype, 3;
	else {	//Success
		successremovecards @part;
		emotion e_ho;
		return 1;
	}
	failedremovecards @part,@failtype;
	if (@failtype == 1)
		mes "The cards were lost...";
	if (@failtype == 2)
		mes "The item was lost...";
	if (@failtype == 0)
		mes "Lost the cards and item...";
	callfunc "F_keIntro", e_swt, "...oops.";
	return 1;
}

}