This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gatcha.txt
106 lines (98 loc) · 3.67 KB
/
gatcha.txt
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
// A simple script where the player can get some defined items at some rates using some defined item
// Example:
// setarray .p0, 671,50, 2462,1,20, 1161,1,30, 5394,1,50; // 50% to get something using a gold coin (id: 671). Then [20/(20+30+50)]% (which is.. 20%) to get the item id 2462.
// https://rathena.org/board/topic/80167-gatcha-item-use-gold-coin-and-tcg/
prontera,155,180,5 script Random 98,{
mes .npc_name$;
mes "Hello, do you want to play ?";
next;
switch( select( "Play !", "More Informations", "Leave" ) ) {
case 1:
break;
case 2:
while( getd(".p"+ .@j ) ) {
mes .npc_name$;
mes "Item required: ^FFCC00"+ getitemname( getd(".p"+ .@j ) ) +"^000000";
mes "Chance to gain something: ^CC0000"+ getd(".p"+ .@j +"[1]" ) +"%^000000";
mes "Possible gains:";
.@total_rates = getd(".totalchance"+ .@j );
for( .@i = 3; .@i < getarraysize( getd(".p"+ .@j ) ); .@i += 3 ) {
.@amount = getd(".p"+ .@j +"["+ .@i +"]" );
.@id = getd(".p"+ .@j +"["+ (.@i -1) +"]" );
.@rates = getd(".p"+ .@j +"["+ (.@i +1) +"]" );
.@percent = .@rates * 100 / .@total_rates;
mes "^0000FFx"+ .@amount +"^000000 "+ getitemname(.@id) +" (^CC0000"+ .@percent +"%^000000)";
}
.@j++;
next;
}
break;
case 3:
mes .npc_name$;
mes "Bye!~";
close;
}
mes .npc_name$;
mes "Which item do you want to use ?";
next;
for( .@j = 0; getd(".p"+ .@j ); .@j++ ) {
.@size = getarraysize( .@menu$ );
.@menu$[ .@size ] = getitemname( getd(".p"+ .@j ) );
.@sel[ .@size ] = .@j;
}
.@s = .@sel[ select( implode( .@menu$, ":" ) ) -1 ];
.@item_required = getd(".p"+ .@s );
.@basic_chance = getd(".p"+ .@s +"[1]" );
.@total_rates = getd(".totalchance"+ .@s );
while (1) {
if ( countitem(.@item_required) < 1 ) {
mes .npc_name$;
mes "It seems you have ran out of "+ getitemname(.@item_required) + ".";
close;
}
mes .npc_name$;
mes "Here we go...";
delitem .@item_required, 1;
if (rand(100) > .@basic_chance) // lose
mes "You got nothing.";
else {
.@rand = rand(.@total_rates);
.@r = 1;
while ( ( .@rand = .@rand - getd( ".p"+ .@s +"["+ (1+ 3 * .@r) +"]" ) ) >= 0 ) .@r++;
.@amount = getd( ".p"+ .@s +"["+( 1+3*.@r -1 )+"]" );
.@id = getd( ".p"+ .@s +"["+ (1+ 3*.@r -2) +"]" );
.@rates = getd( ".p"+ .@s +"["+ (1+ 3 * .@r) +"]" );
.@percent = .@rates * 100 / .@total_rates;
getitem .@id, .@amount;
mes "You got ^FF00CC"+ .@amount +" "+ getitemname(.@id) +"^000000.";
if (.@percent <= .display_announce)
announce strcharinfo(0) + " got ^FF00CC"+ .@amount +" "+ getitemname(.@id) +"^000000 !", 0;
}
mes " ";
mes "wanna try again ?";
next;
if ( select( "Yes", "No" ) == 2 ) close;
}
close;
OnInit:
// (item ID need) (rate), (reward 1) (number of reward 1) (rate to gain), (reward 2) (number of reward 2) (chance to gain)...
// For each array the chance to gain something is : (rate)
// and the chance to gain the item is : [ rate to gain / sum of all the rate ]
setarray .p0, 671,50, 2462,1,20, 1161,1,30, 5394,1,50; // 50% to get something using a gold coin.
setarray .p1, 7227,20, 2462,1,10, 2541,1,10, 1161,1,10, 13517,1,70;
// Below which PERCENT the system display an announce.
// For example in
// setarray .p1, 7227,20, 2462,1,10, 2541,1,10, 1161,1,10, 13517,1,50;
// the chance to get item id 2462 is 10% and the server will display an announce when the player get this item.
.display_announce = 10;
// others
while ( getd(".p"+ .@j) ) {
if (getd(".p"+ .@j +"[1]") > 100)
setd ".p"+ .@j +"[1]", 100;
for( .@i = 4; .@i < getarraysize( getd(".p"+ .@j ) ); .@i += 3 )
setd ".totalchance"+ .@j, getd(".totalchance"+ .@j ) + getd(".p"+ .@j +"["+ .@i +"]" );
.@j++;
}
.npc_name$ = "[ "+ strnpcinfo(1) +"]";
end;
}