Advertisement
Skorm

King of the Hill v2

Jul 30th, 2013
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.43 KB | None | 0 0
  1. //By Skorm v2
  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.     close;
  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;
  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;
  55.     end;
  56.    
  57. OnTimer1000:
  58.     donpcevent "::OnKOHStart";
  59.     announce "King of the hill has started!",0,.st$;
  60.     while(getmapusers(.ma$)&&.koh) {
  61.         sleep 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;
  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;
  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 .ma$, strnpcinfo(4); //Map | For non-rA users manually put your map here in quotes.
  107. }
  108.  
  109. pvp_n_1-1   mapflag loadevent
  110.  
  111. pvp_n_1-1,1,1,0 script  KOH#FX1 139,{
  112. OnKOHStart:
  113.     while(getvariableofnpc(.koh, "King Of The Hill")) {
  114.         sleep .efd;
  115.         specialeffect .eft;
  116.     }
  117.     end;
  118.  
  119. OnInit:
  120.     set .eft, 137; //Number of hill effect.
  121.     set .efd, 50; //Effect Delay.
  122. }
  123.  
  124. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX2 139
  125. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX3 139
  126. pvp_n_1-1,1,1,0 duplicate(KOH#FX1)  KOH#FX4 139
  127.  
  128. function    script  frequency   {
  129. //Configuration
  130.     set .anc, 20; //Delay in seconds to announce the leader.
  131.     set .dal, 1; //Delay in seconds for the announcement of status change.
  132.     set .win, 300; //Winning points.
  133.     set .le$, "0x00FFFF"; //Leader Announce Color.
  134.     set .lo$, "0xFF0000"; //lost control of the hill announce color.
  135.     set .kh$, "0x800080"; //Has won koh color.
  136.     set .ge$, "0x00FF00"; //Gained control of the hill color.
  137.     set .co$, "0xFFFF00"; //Hill congested color.
  138.     set .pon, 500; //Delay in milliseconds to get one point.
  139.     set .pri, 501; //Prize ID.
  140.     set .pam, 10; //Prize Amount.
  141.     set .ma$, getarg(2); //Map
  142.     set .fkn, 1; //Display points in Fakename? (Disable=0 / Enable=1)
  143.     set .dsp, 0; //Display points in chat? (Disable=0 / Enable=1)
  144. //End
  145.  
  146.     if(getarg(3,0)) {
  147.         deletearray .c[0],128;
  148.         deletearray .g[0],128;
  149.         set .t,0;
  150.         for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1)
  151.             setd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000),0);
  152.         return;
  153.     }
  154.  
  155.     set @p,getarg(1);
  156.     set @in,getarg(0);
  157.     getmapxy(.@map$,.@x,.@y,0);
  158.     set .tick, gettimetick(2)+.anc;
  159.     while(.@map$==.ma$&&getvariableofnpc(.koht, "King Of The Hill")) {
  160.         sleep2 1;
  161.         getmapxy(.@map$,.@x,.@y,0);
  162.         if(getvariableofnpc(.koh, "King Of The Hill")) {
  163.             while(.@x<=(getvariableofnpc(.x, "King Of The Hill")+5)&&
  164.                 .@y<=(getvariableofnpc(.y, "King Of The Hill")+5)&&
  165.                 .@x>=getvariableofnpc(.x, "King Of The Hill")&&
  166.                 .@y>=getvariableofnpc(.y, "King Of The Hill")&&
  167.                 Hp!=0&&playerattached()) {
  168.                 getmapxy(.@map$,.@x,.@y,0);
  169.                 sleep2 .pon;
  170.                 if(!@c) {
  171.                     set .c[.p],getcharid(3); set .g[.p],@in;
  172.                     set .p,.p+1; set @c,1;
  173.                     if(.p==1) {
  174.                         mapannounce .ma$,""+strcharinfo(0)+" has gained control of the hill.",0,.ge$;
  175.                         set .b, getcharid(3);
  176.                     }
  177.                 }
  178.                 if(.p>=2&&!.t) {
  179.                     mapannounce .ma$,"Hill Congested!",0,.co$; set .t,1;
  180.                 }
  181.                 if(!.t) {
  182.                     setd ".kohpoints"+@p, getd(".kohpoints"+@p)+1;
  183.                     if(.dsp) dispbottom "You've "+getd(".kohpoints"+@p)+" points";
  184.                     if(.fkn) atcommand "@fakename "+strcharinfo(0)+" ("+getd(".kohpoints"+@p)+"pts)";
  185.                     if(getd(".kohpoints"+@p)>=.win) {
  186.                         announce ""+strcharinfo(0)+" is King of the Hill!!!",0,.kh$;
  187.                         getitem .pri, .pam;
  188.                         for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1)
  189.                             setd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000),0);
  190.                         deletearray .c[0],128;
  191.                         deletearray .g[0],128;
  192.                         set .t,0; set @c,0;
  193.                         if(.fkn) atcommand "@fakename";
  194.                         return;
  195.                     }
  196.                 }
  197.             }
  198.             for(set .@s,0; .@s<getarraysize(.c); set .@s,.@s+1)
  199.                 if(.c[.@s]==getcharid(3)||!isloggedin(.c[.@s])) {
  200.                     if(.b==getcharid(3)&&gettimetick(2)>.tock||
  201.                     !isloggedin(.b)&&gettimetick(2)>.tock) {
  202.                         mapannounce .ma$,""+getelementofarray(getvariableofnpc(.kohplayers$, "King Of The Hill"),.g[.@u])+
  203.                             " has lost control of the hill.",0,.lo$;
  204.                         set .tock, gettimetick(2)+.dal;
  205.                     }
  206.                     set .p,.p-1;
  207.                     if(.p<=1) set .t,0;
  208.                     deletearray .c[.@s],1;
  209.                     deletearray .g[.@s],1;
  210.                     if(playerattached()) set @c,0;
  211.                     set .@s,.@s-1;
  212.                 }
  213.             if(gettimetick(2)>.tick) {
  214.                 set .winningpoints,0;
  215.                 set .tick, gettimetick(2)+.anc;
  216.                 for(set .@u,0; getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u); set .@u,.@u+1) {
  217.                     if(getd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000))
  218.                     >=.winningpoints) {
  219.                         set .winningpoints,
  220.                             getd(".kohpoints"+(getelementofarray(getvariableofnpc(.kohplayers, "King Of The Hill"),.@u)-2000000));
  221.                         set .lead, .@u;
  222.                     }
  223.                 }
  224.                 if(.winningpoints)
  225.                     mapannounce .ma$,""+getelementofarray(getvariableofnpc(.kohplayers$, "King Of The Hill"),.lead)+
  226.                         " is in the lead with "+ .winningpoints +" points.",0,.le$;
  227.             }
  228.             if(.winningpoints>=.win) {
  229.                 if(.fkn) atcommand "@fakename";
  230.                 set @c,0;
  231.                 end;
  232.             }
  233.         }
  234.     }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement