summaryrefslogtreecommitdiff
path: root/npc/items/mercenary.txt
blob: 140d3887be0af031bc2cf03ec30412042493c593 (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
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    Core functions for Mercenary boxset

// Main loop
// merc_boxset(5★, 4★, 3★, 2★, 1★)
function	script	merc_boxset	{
    .@s5=getarg(0,0);
    .@s4=getarg(1,0);
    .@s3=getarg(2,0);
    .@s2=getarg(3,0);
    .@s1=getarg(4,0);

    .@sumup=.@s5+.@s4+.@s3+.@s2+.@s1;
    /* I wonder if this is needed...?
    .@s4+=.@s5;
    .@s3+=.@s4;
    .@s2+=.@s3;
    .@s1+=.@s2;
    */

    // Make the seed. More level and luck increases odds of higher rarity
	.@seed=max(0, rand(0, .@sumup)-BaseLevel-readparam(bLuk));

	// 5 ★
	if (.@seed < .@s5) {
		setarray .@r, MercCard_AndreiSakar, MercCard_Woody, MercCard_Lilanna, MercCard_Xanthem;
		.@n=any_of(.@r);
	// 4 ★
	} else if (.@seed < .@s4) {
		setarray .@r, MercCard_Aisen, MercCard_Msawis, MercCard_Swezanne, MercCard_DragonStar;
		.@n=any_of(.@r);
	// 3 ★
	} else if (.@seed < .@s3) {
		setarray .@r, MercCard_Saulc, MercCard_Crazyfefe, MercCard_LawnCable, MercCard_Arthur;
		.@n=any_of(.@r);
	// 2 ★
	} else if (.@seed < .@s2) {
		setarray .@r, MercCard_Pookie, MercCard_Jesusalva, MercCard_Demure, MercCard_EarthWitch;
		.@n=any_of(.@r);
	// 1 ★
	} else {
		setarray .@r, MercCard_Apane, MercCard_Soren, MercCard_GonzoDark, MercCard_Rosa;
		.@n=any_of(.@r);
	}

	getitem .@n, 1;
    return;
}

/*
// Setup a merc_boxset based on level (TODO)
function	script	cond_mercboxset	{
    return;
}
*/

// Get mercenary ID
// merc_randid(5★, 4★, 3★, 2★, 1★)
function	script	merc_randid	{
    .@s5=getarg(0,0);
    .@s4=getarg(1,0);
    .@s3=getarg(2,0);
    .@s2=getarg(3,0);
    .@s1=getarg(4,0);

    .@sumup=.@s5+.@s4+.@s3+.@s2+.@s1;
    /* I wonder if this is needed...?
    .@s4+=.@s5;
    .@s3+=.@s4;
    .@s2+=.@s3;
    .@s1+=.@s2;
    */

    // Make the seed. More level and luck increases odds of higher rarity
	.@seed=max(0, rand(0, .@sumup)-BaseLevel-readparam(bLuk));

	// 5 ★
	if (.@seed < .@s5) {
		setarray .@r, 1192, 1191, 1193, 1210;
		.@n=any_of(.@r);
	// 4 ★
	} else if (.@seed < .@s4) {
		setarray .@r, 1194, 1195, 1209, 1205;
		.@n=any_of(.@r);
	// 3 ★
	} else if (.@seed < .@s3) {
		setarray .@r, 1196, 1197, 1198, 1208;
		.@n=any_of(.@r);
	// 2 ★
	} else if (.@seed < .@s2) {
		setarray .@r, 1200, 1201, 1199, 1207;
		.@n=any_of(.@r);
	// 1 ★
	} else {
		setarray .@r, 1203, 1204, 1202, 1206;
		.@n=any_of(.@r);
	}

    //debugmes "Return: %d ([%d, %d, %d])", .@n, .@r[0], .@r[1], .@r[2];
	return .@n;
}

// Read the card and return its rarity
// merc_getstar(card)
function	script	merc_getstar	{
    switch (getarg(0)) {
    case MercBoxE:
    case MercBoxEE:
    case MercCard_AndreiSakar:
    case MercCard_Lilanna:
    case MercCard_Woody:
    case MercCard_Xanthem:
        return 5;
    case MercBoxD:
    case MercBoxDD:
    case MercCard_Aisen:
    case MercCard_Msawis:
    case MercCard_DragonStar:
    case MercCard_Swezanne:
        return 4;
    case MercBoxC:
    case MercBoxCC:
    case MercCard_Saulc:
    case MercCard_Crazyfefe:
    case MercCard_LawnCable:
    case MercCard_Arthur:
        return 3;
    case MercBoxB:
    case MercBoxBB:
    case MercCard_Pookie:
    case MercCard_Jesusalva:
    case MercCard_Demure:
    case MercCard_EarthWitch:
        return 2;
    case MercBoxA:
    case MercBoxAA:
    case MercCard_Apane:
    case MercCard_Soren:
    case MercCard_GonzoDark:
    case MercCard_Rosa:
        return 1;
    default:
        return 0;
	}
    return -1;
}