Advertisement
johnlol

Defuse_Bomb

May 10th, 2019
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ________________     ______            ________      
  3. ___    |_____  /________  /______      ___  __ \_____
  4. __  /| |  __  /_  __ \_  __ \  _ \     __  /_/ /  __ \
  5. _  ___ / /_/ / / /_/ /  /_/ /  __/     _  _, _// /_/ /
  6. /_/  |_\__,_/  \____//_.___/\___/      /_/ |_| \____/
  7.  
  8. */
  9.  
  10. prontera,164,155,3  script  Defuse Bomb 851,{
  11. if( .status == 2 ){
  12.     mes "Sorry, event already started.";
  13. }else if( .status == 1 ){
  14.     .aid[ .aid_count ] = getcharid(3);
  15.     .aid_count++;
  16.     @target_wire = @wire_count = 0;
  17.    
  18.     deltimer strnpcinfo(0)+"::OnTimeUp";
  19.     warp .map$,atoi( .map$[1] ),atoi( .map$[2] );
  20. }else{
  21.     mes "No Event now.";
  22. }
  23. end;
  24.  
  25. OnInit:
  26. // Destnation
  27. setarray .map$[0],"quiz_02","335","345";
  28.  
  29. // Wires Name + Location
  30. setarray .wire_name$[0],"RED","GREEN","BLUE","YELLOW","BLACK","WHITE","GOLD","BROWN";
  31. setarray .x[0],329,332,339,342,342,339,332,329;
  32. setarray .y[0],348,352,352,349,343,339,339,342;
  33. .wire_size = getarraysize( .wire_name$ );
  34. .xy_size = getarraysize( .x );
  35.  
  36. // Game Rules
  37. setarray .rules$[0],
  38.     "A Bomb is hidden in this area",
  39.     "You must defuse it within a time given.",
  40.     "To defuse the bomb, you must cut all the wires.",
  41.     "I will tell you which wires to cut from time to time, so please pay attention.",
  42.     "If you made any mistakes, the bomb will explode.",
  43.     "Only cut the wires that I mentioned.",
  44.     "Get Ready, Event Start Now.";
  45. .rules_size = getarraysize( .rules$ );
  46.  
  47. // Time / Wire Range Settings
  48. setarray .wires[0],25,50;
  49. setarray .times[0],45,90;
  50.  
  51. // max game duration
  52. .game_minute = 10;
  53. end;
  54.  
  55. // Event start
  56. OnMinute30:
  57. OnEventStart:
  58.     .status = 1;
  59.     for( .@i = 3; .@i > 0; .@i-- ){
  60.         announce "Defuse Bomb Game registration opened for next "+.@i+" minutes.",0;
  61.         sleep ( 60 * 1000 );
  62.     }
  63.  
  64.     // got participants
  65.     if( .aid_count ){
  66.         .status = 2;
  67.        
  68.         for( .@i = 0; .@i < .rules_size; .@i++ ){
  69.             mapannounce .map$,.rules$[.@i],bc_blue;
  70.             sleep 2500;
  71.         }
  72.        
  73.         copyarray .@wire_name$[0],.wire_name$[0],.xy_size;
  74.         .@wire_size = .wire_size;
  75.         copyarray .@bomb_x[0],.x[0],.xy_size;
  76.         copyarray .@bomb_y[0],.y[0],.xy_size;
  77.         .@xy_size = .xy_size;
  78.         for( .@i = 0; .@i < .xy_size; .@i++ ){
  79.             .@wire_random = rand( .@xy_size );
  80.             .@xy_random = rand( .@xy_size );
  81.             movenpc .@wire_name$[ .@wire_random ],.@bomb_x[ .@xy_random ],.@bomb_y[ .@xy_random ];
  82.            
  83.             deletearray .@wire_name$[ .@wire_random ],1;
  84.             deletearray .@bomb_x[ .@xy_random ],1;
  85.             deletearray .@bomb_y[ .@xy_random ],1;
  86.             .@xy_size--;
  87.         }
  88.  
  89.         mapannounce .map$,"Event Start Now...Defuse the BOMB !!",bc_blue;
  90.         sleep 2500;
  91.  
  92.         for( .@i = 0; .@i < .aid_count; .@i++ )
  93.             if( attachrid( .aid[ .@i ] ) ){
  94.                 .@time = rand( .times[0],.times[1] );
  95.                 @wire_count = rand( .wires[0],.wires[1] );
  96.                 addtimer ( .@time * 1000 ),strnpcinfo(0)+"::OnTimeUp";
  97.                 callsub OnAssign_Wire,.wire_size;
  98.                 dispbottom "You got "+.@time+" seconds for defuse "+@wire_count+" wires.";
  99.             }
  100.  
  101.         sleep ( .game_minute * 60000 );
  102.     }
  103.    
  104. OnEventEnd:
  105.     mapannounce .map$,"Event Ended.",0;
  106.     sleep 2500;
  107.     // clear data
  108.     .status = 0;
  109.     .aid_count = 0;
  110.     deletearray .aid;
  111.     mapwarp .map$,"prontera",155,175;
  112.     end;
  113.    
  114. OnAssign_Wire:
  115.     @target_wire = rand( 1,getarg(0) );
  116.     message strcharinfo(0),"NEXT :  :: "+.wire_name$[ @target_wire - 1 ]+" Wire ::  | "+@wire_count+" left";
  117.     return;
  118.  
  119. OnWire1: callsub OnCheck,1; end;
  120. OnWire2: callsub OnCheck,2; end;
  121. OnWire3: callsub OnCheck,3; end;
  122. OnWire4: callsub OnCheck,4; end;
  123. OnWire5: callsub OnCheck,5; end;
  124. OnWire6: callsub OnCheck,6; end;
  125. OnWire7: callsub OnCheck,7; end;
  126. OnWire8: callsub OnCheck,8; end;
  127.  
  128. OnCheck:
  129.     if( .status == 2 ){
  130.         .@getarg[0] = getarg(0);
  131.        
  132.         // clicked on correct wires.
  133.         if( .@getarg[0] == @target_wire ){
  134.             @wire_count--;
  135.             callsub OnAssign_Wire,.wire_size;
  136.             specialeffect2 610;
  137.            
  138.         // failed / clicked wrong wires
  139.         }else{
  140.             message strcharinfo(0),"You FAILED";
  141.             deltimer strnpcinfo(0)+"::OnTimeUp";
  142.             unitkill getcharid(3);
  143.             specialeffect2 183;
  144.            
  145.             // warp out...
  146.             sleep2 2500;
  147.             warp "prontera",155,181;
  148.         }
  149.        
  150.         // defused all ...
  151.         if( !@wire_count ){
  152.             announce "You success to defuse the BOMB !!",bc_self;
  153.             deltimer strnpcinfo(0)+"::OnTimeUp";
  154.            
  155.             // rewards....
  156.             getitem 12030,25;
  157.             getitem 12259,10;
  158.            
  159.             // warp out...
  160.             sleep2 2500;
  161.             warp "prontera",155,181;
  162.         }
  163.     }
  164.     return;
  165.    
  166. OnTimeUp:
  167.     announce "TIME's UP !!!",0;
  168.     sleep2 2500;
  169.     warp "prontera",155,181;
  170.     end;
  171. }
  172.  
  173.  
  174. // Wire NPCs ( Must Match above .wire_name$ Array )
  175. quiz_02,1,1,4   script  RED 723,{ doevent "Defuse Bomb::OnWire1"; }
  176. quiz_02,1,1,4   script  GREEN   723,{ doevent "Defuse Bomb::OnWire2"; }
  177. quiz_02,1,1,4   script  BLUE    723,{ doevent "Defuse Bomb::OnWire3"; }
  178. quiz_02,1,1,4   script  YELLOW  723,{ doevent "Defuse Bomb::OnWire4"; }
  179. quiz_02,1,1,4   script  BLACK   723,{ doevent "Defuse Bomb::OnWire5"; }
  180. quiz_02,1,1,4   script  WHITE   723,{ doevent "Defuse Bomb::OnWire6"; }
  181. quiz_02,1,1,4   script  GOLD    723,{ doevent "Defuse Bomb::OnWire7"; }
  182. quiz_02,1,1,4   script  BROWN   723,{ doevent "Defuse Bomb::OnWire8"; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement