Advertisement
Skorm

KOTH v2.1

Aug 7th, 2013
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.71 KB | None | 0 0
  1. //By Skorm v2.1
  2. prontera.gat,207,143,5  script  Koh 120,{
  3.     if(!getgmlevel()) end;
  4.         if(select("Start KOH:NO")==1) {
  5.             donpcevent "King Of The Hill::OnClock1230";
  6.         }
  7.     end;
  8. }
  9.  
  10. pvp_n_1-1,89,39,5   script  King Of The Hill    139,{
  11. end;
  12. OnClock1230:
  13. OnClock1430:
  14. OnClock1630:
  15. OnClock1830:
  16.     stopnpctimer;
  17.     set .koh,0; cleararray .kohplayers[0],0,100;
  18.     set .in,0; set .koht, 1;
  19.     //announce "King of The Hill will start in Pvp1 in 3 minutes!",0;
  20.     //sleep 60000;
  21.     //announce "King of The Hill will start in 2 minutes!!",0;
  22.     //sleep 60000;
  23.     announce "King of The Hill will start 1 minute!!",0;
  24.     set .x,rand(500);
  25.     set .y,rand(500);
  26.     while( !checkcell("pvp_n_1-1",.x+2,.y+3,cell_chkpass) ) {
  27.             set .x,rand(500);
  28.             set .y,rand(500);
  29.     }
  30.     sleep 60000; set .koh,1;
  31.     setnpctimer 0; startnpctimer;
  32.     end;
  33.    
  34. OnPCLoadMapEvent:
  35.     if(strcharinfo(3)!=.ma$) end;
  36.  
  37.     if(!.koht) end;
  38.     for(set .@t,0; .@t<getarraysize(.kohplayers); set .@t,.@t+1) {
  39.         if(.kohplayers[.@t]==getcharid(3)) {
  40.             callfunc "frequency",.@t,(getcharid(3)-2000000),.ma$;
  41.             stopnpctimer;
  42.             set .koh,0; cleararray .kohplayers[0],0,100;
  43.             set .in,0; set .koht,0; set .koth, 0;
  44.             end;
  45.         }
  46.     }
  47.     mapannounce .ma$,""+strcharinfo(0)+" has joined King of the Hill.",0,.jn$;
  48.     set .kohplayers[.in],getcharid(3);
  49.     set .kohplayers$[.in],strcharinfo(0);
  50.     set .in,.in+1;
  51.     callfunc "frequency",(.in-1),(getcharid(3)-2000000),.ma$;
  52.     stopnpctimer;
  53.     set .koh,0; cleararray .kohplayers[0],0,100;
  54.     set .in,0; set .koht,0; set .koth, 0;
  55.     end;
  56.    
  57. OnTimer1000:
  58.     donpcevent "::OnKOHStart";
  59.     announce "King of the hill has started!",0,.st$;
  60.     while(getmapusers(.ma$)>=.num&&.koh||.koth&&.koh) {
  61.         sleep 1; set .koth, 1;
  62.         for(set .@d,0; .@d < 5;set .@d,.@d+1) {
  63.             sleep .aft;
  64.             movenpc "KOH#FX1",.x,(.y+.@d);
  65.             movenpc "KOH#FX2",(.x+.@d),(.y+5);
  66.             movenpc "KOH#FX3",(.x+5),((.y+5)-.@d);
  67.             movenpc "KOH#FX4",((.x+5)-.@d),.y;
  68.         }
  69.     }
  70.     if(.koh) announce "Not enough players King of the hill has ended!",0,.nt$;
  71.     stopnpctimer;
  72.     set .koht,0; set .koh,0; set .koth,0;
  73.     callfunc "frequency",0,2000000,.ma$,1;
  74.     cleararray .kohplayers[0],0,100;
  75.     set .in,0;
  76.     end;
  77.    
  78. OnTimer16000:
  79.     if(!.koh){ stopnpctimer; end; }
  80.     sleep rand(.hil[0],.hil[1]);
  81.     set .x,rand(500);
  82.     set .y,rand(500);
  83.     while( !checkcell(.ma$,.x+2,.y+3,cell_chkpass) ) {
  84.         set .x,rand(500);
  85.         set .y,rand(500);
  86.     }
  87.     if(.koh) mapannounce .ma$,"The Hill has moved!",0,.hm$;
  88.     goto OnTimer16000;
  89.  
  90. OnTimer1800000:
  91.     announce "King of the Hill has ended there was no winner.",0,.nt$;
  92.     stopnpctimer;
  93.     set .koht,0; set .koh,0; set .koth,0;
  94.     callfunc "frequency",0,2000000,.ma$,1;
  95.     cleararray .kohplayers[0],0,100;
  96.     set .in,0;
  97.     end;
  98.    
  99. OnInit:
  100.     setarray .hil, 30000, 60000; //Delay for the hill to move in milliseconds range.
  101.     set .hm$, "0xFFAF0A"; //Hill moved color.
  102.     set .nt$, "0xFFAF0A"; //Not enough players color.
  103.     set .st$, "0xFFAF0A"; //KOH started colors.
  104.     set .jn$, "0x00FFFF"; //Join KOH colors.
  105.     set .aft, 500; //Delay of Hill effect in milliseconds.
  106.     set .num, 2; //Number of players allowed to start the event.
  107.     set .ma$, strnpcinfo(4); //Map | For non-rA users manually put your map here in quotes.
  108. }
  109.  
  110. pvp_n_1-1   mapflag loadevent
  111.  
  112. pvp_n_1-1,1,1,0 script  KOH#FX1 139,{
  113. OnKOHStart:
  114.     while(getvariableofnpc(.koh, "King Of The Hill")) {
  115.         sleep .efd;
  116.         specialeffect .eft;
  117.     }
  118.     end;
  119.  
  120. OnInit:
  121.     set .eft, 137; //Number of hill effect.
  122.     set .efd, 50; //Effect Delay.
  123. }
  124.  
  125. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX2 139
  126. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX3 139
  127. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX4 139
  128.  
  129. function    script  frequency   {
  130. //Configuration
  131.     set .anc, 20; //Delay in seconds to announce the leader.
  132.     set .dal, 1; //Delay in seconds for the announcement of status change.
  133.     set .win, 300; //Winning points.
  134.     set .le$, "0x00FFFF"; //Leader Announce Color.
  135.     set .lo$, "0xFF0000"; //lost control of the hill announce color.
  136.     set .kh$, "0x800080"; //Has won koh color.
  137.     set .ge$, "0x00FF00"; //Gained control of the hill color.
  138.     set .co$, "0xFFFF00"; //Hill congested color.
  139.     set .pon, 500; //Delay in milliseconds to get one point.
  140.     set .war, 1; //Warp players off the map when event is finished.(Disable=0 / Enable=1)
  141.     set .pri, 501; //Prize ID.
  142.     set .pam, 10; //Prize Amount.
  143.     set .ma$, getarg(2); //Map
  144.     set .fkn, 1; //Display points in Fakename? (Disable=0 / Enable=1)
  145.     set .dsp, 0; //Display points in chat? (Disable=0 / Enable=1)
  146. //End
  147.  
  148.     if(getarg(3,0)) {
  149.         deletearray .c[0],128;
  150.         deletearray .g[0],128;
  151.         set .t,0;
  152.         for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1)
  153.             setd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000),0);
  154.         return;
  155.     }
  156.  
  157.     set @p,getarg(1);
  158.     set @in,getarg(0);
  159.     getmapxy(.@map$,.@x,.@y,0);
  160.     set .tick, gettimetick(2)+.anc;
  161.     while(.@map$==.ma$&&getvariableofnpc(.koht, "King Of The Hill")) {
  162.         sleep2 1;
  163.         getmapxy(.@map$,.@x,.@y,0);
  164.         if(getvariableofnpc(.koh, "King Of The Hill")) {
  165.             while(.@x<=(getvariableofnpc(.x, "King Of The Hill")+5)&&
  166.                 .@y<=(getvariableofnpc(.y, "King Of The Hill")+5)&&
  167.                 .@x>=getvariableofnpc(.x, "King Of The Hill")&&
  168.                 .@y>=getvariableofnpc(.y, "King Of The Hill")&&
  169.                 Hp!=0&&playerattached()) {
  170.                 getmapxy(.@map$,.@x,.@y,0);
  171.                 sleep2 .pon;
  172.                 if(!@c) {
  173.                     set .c[.p],getcharid(3); set .g[.p],@in;
  174.                     set .p,.p+1; set @c,1;
  175.                     if(.p==1) {
  176.                         mapannounce .ma$,""+strcharinfo(0)+" has gained control of the hill.",0,.ge$;
  177.                         set .b, getcharid(3);
  178.                     }
  179.                 }
  180.                 if(.p>=2&&!.t) {
  181.                     mapannounce .ma$,"Hill Congested!",0,.co$; set .t,1;
  182.                 }
  183.                 if(!.t) {
  184.                     setd ".kohpoints"+@p, getd(".kohpoints"+@p)+1;
  185.                     if(.dsp) dispbottom "You've "+getd(".kohpoints"+@p)+" points";
  186.                     if(.fkn) atcommand "@fakename "+strcharinfo(0)+" ("+getd(".kohpoints"+@p)+"pts)";
  187.                     if(getd(".kohpoints"+@p)>=.win) {
  188.                         announce ""+strcharinfo(0)+" is King of the Hill!!!",0,.kh$;
  189.                         getitem .pri, .pam;
  190.                         for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1)
  191.                             setd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000),0);
  192.                         deletearray .c[0],128;
  193.                         deletearray .g[0],128;
  194.                         set .t,0; set @c,0;
  195.                         if(.fkn) atcommand "@fakename";
  196.                         if(.war) mapwarp .ma$,"prontera",100,100;
  197.                         return;
  198.                     }
  199.                 }
  200.             }
  201.             for(set .@s,0; .@s<getarraysize(.c); set .@s,.@s+1)
  202.                 if(.c[.@s]==getcharid(3)||!isloggedin(.c[.@s])) {
  203.                     if(.b==getcharid(3)&&gettimetick(2)>.tock||
  204.                     !isloggedin(.b)&&gettimetick(2)>.tock) {
  205.                         mapannounce .ma$,""+getelementofarray(getvariableofnpc(.kohplayers$, "King Of The Hill"),.g[.@u])+
  206.                             " has lost control of the hill.",0,.lo$;
  207.                         set .tock, gettimetick(2)+.dal;
  208.                     }
  209.                     set .p,.p-1;
  210.                     if(.p<=1) set .t,0;
  211.                     deletearray .c[.@s],1;
  212.                     deletearray .g[.@s],1;
  213.                     if(playerattached()) set @c,0;
  214.                     set .@s,.@s-1;
  215.                 }
  216.             if(gettimetick(2)>.tick) {
  217.                 set .winningpoints,0;
  218.                 set .tick, gettimetick(2)+.anc;
  219.                 for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1) {
  220.                     if(getd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000))
  221.                     >=.winningpoints) {
  222.                         set .winningpoints,
  223.                             getd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000));
  224.                         set .lead, .@u;
  225.                     }
  226.                 }
  227.                 if(.winningpoints)
  228.                     mapannounce .ma$,""+getelementofarray(getvariableofnpc(.kohplayers$, "King Of The Hill"),.lead)+
  229.                         " is in the lead with "+ .winningpoints +" points.",0,.le$;
  230.             }
  231.             if(.winningpoints>=.win) {
  232.                 if(.fkn) atcommand "@fakename";
  233.                 set @c,0;
  234.                 end;
  235.             }
  236.         }
  237.     }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement