Advertisement
Emistry

[RO] Arithmetic Contest 1.1

Apr 11th, 2020
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.01 KB | None | 0 0
  1. // https://rathena.org/board/topic/123368-request-npc-arithmetic-tales-of-eternia/
  2.  
  3. prontera,155,181,5  script  Arithmetic Contest  4_F_KAFRA1,{
  4.    
  5.     mes "^0055FF[ Arithmetic Contest ]^000000";
  6.     mes "Would you take the contest?";
  7.     next;
  8.     if (select("Yes", "No") == 1) {
  9.         for (.@i = 0; .@i < .max_stone_pile; .@i++)
  10.             .@stone_pile_list[.@i] = rand(0, .max_stone_per_pile);
  11.        
  12.         do {
  13.             mes "^0055FF[ Arithmetic Contest ]^000000";
  14.             .@menu$ = "";
  15.             .@pick_menu$ = "";
  16.             for (.@i = 0; .@i < .max_stone_pile; .@i++) {
  17.                 mes "Stone Pile "+(.@i+1)+" -> "+.@stone_pile_list[.@i] +" stone(s)";
  18.                 if (.@stone_pile_list[.@i] > 0)
  19.                     .@menu$ = .@menu$ + "Stone Pile "+(.@i+1)+" -> "+.@stone_pile_list[.@i];
  20.                 .@menu$ = .@menu$ + ":";
  21.             }
  22.             .@stone_pile = select(.@menu$) - 1;
  23.             for (.@i = 0; .@i < .max_pick_per_round && .@i < .@stone_pile_list[.@stone_pile]; .@i++)
  24.                 .@pick_menu$ = .@pick_menu$ + "Pick "+(.@i+1) + " stone(s)" + ":";
  25.             .@pick = select(.@pick_menu$);
  26.             .@stone_pile_list[.@stone_pile] -= .@pick;
  27.             mes " ";
  28.             mes "Player picked "+.@pick+" from Pile "+(.@stone_pile+1);
  29.             if (callsub(L_IsEmpty, .@stone_pile_list)) {
  30.                 mes "Player win the contest!";
  31.                 getitem 512, 1;
  32.                 break;
  33.             }
  34.            
  35.             do {
  36.                 .@stone_pile = rand(.max_stone_pile);
  37.             } while (.@stone_pile_list[.@stone_pile] <= 0);
  38.             if (.@stone_pile_list[.@stone_pile] <= .max_pick_per_round)
  39.                 .@pick = .@stone_pile_list[.@stone_pile];
  40.             else
  41.                 .@pick = rand(1, min(.max_pick_per_round, .@stone_pile_list[.@stone_pile]));
  42.             mes "NPC picked "+.@pick+" from Pile "+(.@stone_pile+1);
  43.             .@stone_pile_list[.@stone_pile] -= .@pick;
  44.             if (callsub(L_IsEmpty, .@stone_pile_list)) {
  45.                 mes "NPC win the contest!";
  46.                 break;
  47.             }
  48.             next;
  49.         } while (1);
  50.     }
  51.     close;
  52.    
  53.     L_IsEmpty:
  54.         for (.@i = 0; .@i < .max_stone_pile; .@i++) {
  55.             if (getelementofarray(getarg(0), .@i) > 0)
  56.                 return 0;
  57.         }
  58.         return 1;
  59.    
  60.     OnInit:
  61.         .max_stone_pile = 3;
  62.         .max_stone_per_pile = 12;
  63.         .max_pick_per_round = 3;
  64.         end;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement