· 9 years ago · Oct 31, 2016, 10:52 AM
1
2/*
3CREATE TABLE IF NOT EXISTS `e_rebirth_list` (
4 `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
5 `rebirth` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
6 `blv` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
7 `jlv` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
8 `stpoint` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
9 `skpoint` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
10 PRIMARY KEY (`id`),
11 KEY (`rebirth`)
12) ENGINE=MyISAM;
13
14CREATE TABLE IF NOT EXISTS `e_rebirth_items` (
15 `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
16 `rebirth` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
17 `nameid` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
18 `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
19 PRIMARY KEY (`id`),
20 KEY (`rebirth`)
21) ENGINE=MyISAM;
22
23CREATE TABLE IF NOT EXISTS `e_rebirth_rewards` (
24 `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
25 `rebirth` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
26 `nameid` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
27 `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
28 PRIMARY KEY (`id`),
29 KEY (`rebirth`)
30) ENGINE=MyISAM;
31
32*/
33
34
35prontera,155,181,5 script Rebirth_NPC1 757,{
36 if ( BaseClass == Job_Summoner ) {
37 mes "Only non-Summoner class can rebirth.";
38 close;
39 }
40 else {
41 doevent "rebirth_npc_main::OnTalk";
42 }
43}
44
45prontera,155,181,5 script Rebirth_NPC2 757,{
46 if ( BaseClass != Job_Summoner ) {
47 mes "Only Summoner class can rebirth.";
48 close;
49 }
50 else {
51 doevent "rebirth_npc_main::OnTalk";
52 }
53}
54
55- script rebirth_npc_main -1,{
56
57 function AddRebirth {
58 .@rebirth = getarg(0,0);
59 .@blv = getarg( 1,175 );
60 .@jlv = getarg( 2,60 );
61 .@stpoint = getarg( 3,0 );
62 .@stpoint = getarg( 4,0 );
63
64 if ( .@rebirth && .@nameid && .@amount ) {
65 query_sql( "INSERT INTO `e_rebirth_items` ( `rebirth`,`blv`,`jlv`,`stpoint`,`skpoint` )VALUES ( "+.@rebirth+","+.@blv+","+.@jlv+","+.@stpoint+","+.@skpoint+" )" );
66 }
67 return;
68 }
69
70 function AddRequirement {
71 .@rebirth = getarg(0,0);
72 .@argcount = getargcount() - 1;
73
74 for ( .@i = 1; .@i < .@argcount; .@i += 2 ) {
75 .@nameid = getarg( .@i,0 );
76 .@amount = getarg( .@i+1,0 );
77 if ( .@rebirth && .@nameid && .@amount ) {
78 query_sql( "INSERT INTO `e_rebirth_items` ( `rebirth`,`nameid`,`amount` )VALUES ( "+.@rebirth+","+.@amount+","+.@amount+" )" );
79 }
80 }
81 return;
82 }
83
84 function AddReward {
85 .@rebirth = getarg(0,0);
86 .@argcount = getargcount() - 1;
87
88 for ( .@i = 1; .@i < .@argcount; .@i += 2 ) {
89 .@nameid = getarg( .@i,0 );
90 .@amount = getarg( .@i+1,0 );
91 if ( .@rebirth && .@nameid && .@amount ) {
92 query_sql( "INSERT INTO `e_rebirth_rewards` ( `rebirth`,`nameid`,`amount` )VALUES ( "+.@rebirth+","+.@amount+","+.@amount+" )" );
93 }
94 }
95 return;
96 }
97
98 OnInit:
99 query_sql( "TRUNCATE `e_rebirth_list`" );
100 query_sql( "TRUNCATE `e_rebirth_items`" );
101 query_sql( "TRUNCATE `e_rebirth_rewards`" );
102
103 for ( .@i = 1; .@i <= 100; .@i++ ) {
104 AddRebirth( .@i, 175, 60, 5, ( .@i % 10 == 0 ) );
105 AddRequirement( .@i,501,.@i,502,.@i,503,.@i,504,.@i );
106 AddReward( .@i,501,.@i,502,.@i,503,.@i,504,.@i );
107 if ( .@i % 10 == 0 )
108 sleep 1;
109 }
110 end;
111
112 OnTalk:
113 mes "Hello, "+strcharinfo(0)+",";
114 mes "You want to rebirth ?";
115 next;
116 switch ( select(
117 "My Rebirth Information",
118 "Yes, I want to Rebirth",
119 "Reset Status",
120 "Reset Skill"
121 ) ) {
122 default:
123 case 1:
124 mes "Current Rebirth: "+REBIRTH_COUNT;
125 mes " ";
126 query_sql( "SELECT SUM(`stpoint`),SUM(`skpoint`) FROM `e_rebirth_list` WHERE `rebirth` <= "+REBIRTH_COUNT,.@total_stpoint, .@total_skpoint);
127 mes "Bonus StatusPoint: "+.@total_stpoint;
128 mes "Bonus SkillPoint: "+.@total_skpoint;
129 break;
130 case 2:
131 query_sql( "SELECT `id`,`blv`,`jlv`,`stpoint`,`skpoint` FROM `e_rebirth_list` WHERE `rebirth` = "+( REBIRTH_COUNT + 1 )+" LIMIT 1", .@id,.@blv,.@jlv,.@stpoint,.@skpoint );
132 if ( !.@id ) {
133 mes "You have reach the max rebirth, or rebirth isn't available for you now.";
134 }
135 else {
136 query_sql( "SELECT `nameid`,`amount` FROM `e_rebirth_items` WHERE `rebirth` = "+( REBIRTH_COUNT + 1 ), .@req_nameid,.@req_amount );
137 .@req_item_size = getarraysize( .@req_nameid );
138 query_sql( "SELECT `nameid`,`amount` FROM `e_rebirth_rewards` WHERE `rebirth` = "+( REBIRTH_COUNT + 1 ), .@reward_nameid,.@reward_amount );
139 .@reward_item_size = getarraysize( .@reward_nameid );
140
141 mes "^0055FF[ Rebirth "+( REBIRTH_COUNT + 1 )+"th time ]^000000";
142 mes "Required Level : "+.@blv+" / "+.@jlv;
143 if ( BaseLevel < .@blv || JobLevel < .@jlb )
144 .@fail++;
145
146 if ( .@req_item_size ) {
147 mes " ";
148 mes "Required Items :";
149 for ( .@i = 0; .@i < .@req_item_size; .@i++ ) {
150 mes "^777777 ~ "+.@req_amount[.@i]+"x "+getitemname( .@req_nameid[.@i] );
151 if ( countitem( .@req_nameid[.@i] ) < .@req_amount[.@i] )
152 .@fail++;
153 }
154 }
155 if ( .@reward_item_size ) {
156 mes " ";
157 mes "Rewards Items :";
158 for ( .@i = 0; .@i < .@reward_item_size; .@i++ ) {
159 mes "^777777 ~ "+.@reward_amount[.@i]+"x "+getitemname( .@reward_nameid[.@i] );
160 }
161 }
162 if ( .@stpoint || .@skpoint ) {
163 mes " ";
164 mes "Extra Benefits :";
165 if ( .@stpoint ) mes "Status Point: +"+.@stpoint;
166 if ( .@skpoint ) mes "Skill Point: +"+.@skpoint;
167 }
168 if ( !.@fail ) {
169 next;
170 if ( select( "Rebirth","Cancel" ) == 1 ) {
171
172 if ( .@req_item_size ) {
173 for ( .@i = 0; .@i < .@req_item_size; .@i++ )
174 delitem .@req_nameid[.@i],.@req_amount[.@i];
175 }
176 resetlvl 1;
177 REBIRTH_COUNT++;
178 query_sql( "SELECT SUM(`stpoint`),SUM(`skpoint`) FROM `e_rebirth_list` WHERE `rebirth` <= "+REBIRTH_COUNT,.@total_stpoint, .@total_skpoint);
179 StatusPoint += .@total_stpoint;
180 SkillPoint += .@total_skpoint;
181 if ( .@reward_item_size ) {
182 for ( .@i = 0; .@i < .@reward_item_size; .@i++ )
183 getitem .@reward_nameid[.@i],.@reward_amount[.@i];
184 }
185 mes "Done, rebirth "+REBIRTH_COUNT+"th time.";
186 }
187 }
188 }
189 break;
190 case 3:
191 resetstatus;
192 query_sql( "SELECT SUM(`stpoint`) FROM `e_rebirth_list` WHERE `rebirth` <= "+REBIRTH_COUNT,.@total_stpoint);
193 StatusPoint += .@total_stpoint;
194 mes "Done reset, you got total "+StatusPoint+" StatusPoint.";
195 break;
196 case 4:
197 resetskill;
198 query_sql( "SELECT SUM(`skpoint`) FROM `e_rebirth_list` WHERE `rebirth` <= "+REBIRTH_COUNT,.@total_skpoint);
199 SkillPoint += .@total_skpoint;
200 mes "Done reset, you got total "+SkillPoint+" SkillPoint.";
201 break;
202 }
203 close;
204}