Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://rathena.org/board/topic/123368-request-npc-arithmetic-tales-of-eternia/
- prontera,155,181,5 script Arithmetic Contest 4_F_KAFRA1,{
- mes "^0055FF[ Arithmetic Contest ]^000000";
- mes "Would you take the contest?";
- next;
- if (select("Yes", "No") == 1) {
- for (.@i = 0; .@i < .max_stone_pile; .@i++)
- .@stone_pile_list[.@i] = rand(0, .max_stone_per_pile);
- do {
- mes "^0055FF[ Arithmetic Contest ]^000000";
- .@menu$ = "";
- .@pick_menu$ = "";
- for (.@i = 0; .@i < .max_stone_pile; .@i++) {
- mes "Stone Pile "+(.@i+1)+" -> "+.@stone_pile_list[.@i] +" stone(s)";
- if (.@stone_pile_list[.@i] > 0)
- .@menu$ = .@menu$ + "Stone Pile "+(.@i+1)+" -> "+.@stone_pile_list[.@i];
- .@menu$ = .@menu$ + ":";
- }
- .@stone_pile = select(.@menu$) - 1;
- for (.@i = 0; .@i < .max_pick_per_round && .@i < .@stone_pile_list[.@stone_pile]; .@i++)
- .@pick_menu$ = .@pick_menu$ + "Pick "+(.@i+1) + " stone(s)" + ":";
- .@pick = select(.@pick_menu$);
- .@stone_pile_list[.@stone_pile] -= .@pick;
- mes " ";
- mes "Player picked "+.@pick+" from Pile "+(.@stone_pile+1);
- if (callsub(L_IsEmpty, .@stone_pile_list)) {
- mes "Player win the contest!";
- getitem 512, 1;
- break;
- }
- do {
- .@stone_pile = rand(.max_stone_pile);
- } while (.@stone_pile_list[.@stone_pile] <= 0);
- if (.@stone_pile_list[.@stone_pile] <= .max_pick_per_round)
- .@pick = .@stone_pile_list[.@stone_pile];
- else
- .@pick = rand(1, min(.max_pick_per_round, .@stone_pile_list[.@stone_pile]));
- mes "NPC picked "+.@pick+" from Pile "+(.@stone_pile+1);
- .@stone_pile_list[.@stone_pile] -= .@pick;
- if (callsub(L_IsEmpty, .@stone_pile_list)) {
- mes "NPC win the contest!";
- break;
- }
- next;
- } while (1);
- }
- close;
- L_IsEmpty:
- for (.@i = 0; .@i < .max_stone_pile; .@i++) {
- if (getelementofarray(getarg(0), .@i) > 0)
- return 0;
- }
- return 1;
- OnInit:
- .max_stone_pile = 3;
- .max_stone_per_pile = 12;
- .max_pick_per_round = 3;
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement