Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.33 KB | None | 0 0
  1. // [========================================================]
  2. // [===========           The Invasor            ===========]
  3. // [========================================================]
  4. // [ Version 10                                             ]
  5. // [========================================================]
  6. // [ Original script by: Ivion                              ]
  7. // [========================================================]
  8.  
  9. -   script  invasor -1,{
  10.  
  11. OnInit:
  12.  
  13. // [========================================================]
  14. // [ Configuration:                                         ]
  15. // [--------------------------------------------------------]
  16.  
  17.     set .t1,2*24;       // Minimum time to activate a new invasion event. (h)
  18.     set .t2,14*24;      // Maximum time to activate a new invasion event. (h)
  19.     set .t3,24*60;      // Maximum duration of the invasion event. (min)
  20.  
  21.     set .r1,100;        // Mob rate. (%)
  22.     set .pci,7539;      // Item reward dropped by mobs and bosses. (Default = Poring Coin)
  23.     set .pcr1,100;      // Rate of item rewards dropped by mobs. (0 = off | %)
  24.     set .pcr2,100;      // Rate of item rewards dropped by bosses. (0 = off | %)
  25.  
  26.     set .t4,60;     // Duration of the experience event after defeating the invader armies. (0 = off | min)
  27.     set .r2,100;        // Base exp rate increment. (0 = off | %)
  28.     set .r3,100;        // Job exp rate increment. (0 = off | %)
  29.  
  30.     set .gm,60;     // GM level required to access the Control Panel whispering to NPC:invasor.
  31.  
  32.     // Alternative Save Point:
  33.     // If a player had saved in the map of the current invasion event, his respawn point will be changed to this one.
  34.  
  35.     set .s$,"prontera"; // Map.
  36.     set .sx,156;        // x.
  37.     set .sy,161;        // y.
  38.  
  39.     // Cities:
  40.     // getarg(0): Name.
  41.     // getarg(1): Map.
  42.     // getarg(2): Intensity. (0 = off | Intensity)
  43.  
  44.     callsub Onc0,"Alberta","alberta",11;
  45.     callsub Onc0,"Al De Baran","aldebaran",14;
  46.     callsub Onc0,"Amatsu","amatsu",18;
  47.     callsub Onc0,"Ayothaya","ayothaya",8;
  48.     callsub Onc0,"Brasilis","brasilis",27;
  49.     callsub Onc0,"Comodo","comodo",22;
  50.     callsub Onc0,"Einbech","einbech",11;
  51.     callsub Onc0,"Einbroch","einbroch",22;
  52.     callsub Onc0,"El Dicastes","dicastes01",14;
  53.     callsub Onc0,"Geffen","geffen",10;
  54.     callsub Onc0,"Gonryun","gonryun",14;
  55.     callsub Onc0,"Hugel","hugel",9;
  56.     callsub Onc0,"Izlude","izlude",5;
  57.     callsub Onc0,"Jawaii","jawaii",0; // 7
  58.     callsub Onc0,"Juno","yuno",30;
  59.     callsub Onc0,"Lighthalzen","lighthalzen",24;
  60.     callsub Onc0,"Louyang","louyang",27;
  61.     callsub Onc0,"Lutie","xmas",20;
  62.     callsub Onc0,"Manuk","manuk",8;
  63.     callsub Onc0,"Midgarts Expedition Camp","mid_camp",13;
  64.     callsub Onc0,"Morroc","morocc",26;
  65.     callsub Onc0,"Moscovia","moscovia",6;
  66.     callsub Onc0,"Niflheim","niflheim",0; // 20
  67.     callsub Onc0,"Payon","payon",19;
  68.     callsub Onc0,"Prontera","prontera",0; // 30
  69.     callsub Onc0,"Rachel","rachel",18;
  70.     callsub Onc0,"Splendide","splendide",29;
  71.     callsub Onc0,"Umbala","umbala",4;
  72.     callsub Onc0,"Veins","veins",20;
  73.  
  74.     // Invaders:
  75.     // getarg(0): Name.
  76.     // getarg(1 .. 9): Mobs.
  77.     // getarg(10 .. 12): Bosses.
  78.  
  79.     callsub Onc1,"Aqua",1001,1002,1002,1002,1002,1001,1002,1001,1002,1001,1002;
  80. //  callsub Onc1,"Aqua",1068,1071,1228,1069,1044,1144,1045,1065,1264,2503,2504,2505;
  81. //  callsub Onc1,"Demon",1146,1109,1101,1149,1632,1773,1382,1292,1208,2536,2537,2538;
  82. //  callsub Onc1,"Dragon",1715,1718,1155,1380,1206,1385,1717,1714,1716,2524,2525,2526;
  83. //  callsub Onc1,"Earth",1784,1782,1165,1517,1615,1516,1378,1386,1602,2512,2513,2514;
  84. //  callsub Onc1,"Fire",1836,1367,1383,1072,1384,1381,1318,1837,1366,2500,2501,2502;
  85. //  callsub Onc1,"Ghost",1509,1179,1186,1143,1510,1192,1506,1375,1291,2527,2528,2529;
  86. //  callsub Onc1,"Ice",1243,1789,1776,1778,1323,1317,1775,1515,1319,2506,2507,2508;
  87. //  callsub Onc1,"Insect",1054,1100,1139,1279,1099,1625,1304,1194,1305,2518,2519,2520;
  88. //  callsub Onc1,"Kaos",1140,1508,1163,1276,1504,1132,1698,1505,1507,2539,2540,2541;
  89. //  callsub Onc1,"Machina",1151,1616,1745,1682,1270,1622,1202,1678,1673,2515,2516,2517;
  90. //  callsub Onc1,"Nature",1162,1118,1880,1500,1497,1410,1780,1884,1314,2509,2510,2511;
  91. //  callsub Onc1,"Takeshi",1026,1188,1404,1584,1609,1512,1416,1405,1401,2542,2543,2544;
  92. //  callsub Onc1,"Undead",1403,1169,1041,1196,1197,1117,1297,1866,1098,2533,2534,2535;
  93. //  callsub Onc1,"Venom",1621,1256,1037,1402,1209,1216,1207,1883,1148,2521,2522,2523;
  94. //  callsub Onc1,"Wind",1627,1156,1253,1263,1633,1692,1412,1774,1259,2530,2531,2532;
  95.  
  96. // [--------------------------------------------------------]
  97. // [ End of configuration.                                  ]
  98. // [========================================================]
  99.  
  100.     // Restore experience rates:
  101.     if(checkcell("prontera",0,0,cell_water)) {
  102.         setbattleflag "base_exp_rate",getbattleflag("base_exp_rate") - $TIbr;
  103.         setbattleflag "job_exp_rate",getbattleflag("job_exp_rate") - $TIjr;
  104.         set $TIbr,0;
  105.         set $TIjr,0;
  106.         setcell "prontera",0,0,0,0,cell_water,0;
  107.         atcommand "@reloadmobdb";
  108.     }
  109.  
  110.     // Fix incorrect map cells:
  111.     setcell "amatsu",314,267,314,314,0,0;
  112.     setcell "yuno",205,219,205,218,0,0;
  113.  
  114.     while(1) {
  115.         set .a,0; // Stage.
  116.         set .b,0; // Class.
  117.         set .c,0; // City.
  118.         set .@t,gettimetick(2) / 60;
  119.         if($TIt <= .@t) set $TIt,.@t + rand(.t1 * 60,.t2 * 60);
  120.         do {
  121.             if(($TIt - .@t) / (24 * 60)) sleep 24 * 60 * 60 * 1000;
  122.             else sleep ($TIt - .@t) * 60 * 1000;
  123.             set .@t,gettimetick(2) / 60;
  124.         } while(.@t < $TIt);
  125.         set .a,1;
  126.         set $TIt,0;
  127.         set .@t,0;
  128.         donpcevent "invasor::OnTimer";
  129.         if(!.b) set .b,rand(1,getarraysize(.i));
  130.         set .b,.b - 1;
  131.         if(!.c) set .c,rand(1,getarraysize(.n$));
  132.         set .c,.c - 1;
  133.         set .mf1,getmapflag(.c2$[.b],1);
  134.         set .mf4,getmapflag(.c2$[.b],4);
  135.         setmapflag .c2$[.b],1; // noteleport
  136.         setmapflag .c2$[.b],4; // nopenalty
  137.         callsub Clrmsg;
  138.         announce "S.O.S.!! "+.c1$[.b]+" is suffering from a terrible invasion.",bc_all,0xffaa00;
  139.         while(.a > 0) {
  140.             if(!.d) {
  141.                 set .d,4 - .a;
  142.                 killmonster .c2$[.b],"invasor::Onm9";
  143.                 if(.a > 1) callsub Addmsg,"New invader armies comes into the city.","ffaa00",.c2$[.b];
  144.                 monster .c2$[.b],0,0,"--ja--",getd(".m"+((.c * 12) + .a + 8)),4 - .a,"invasor::Onm9";
  145.             }
  146.             set .@a,3;
  147.             while(.@a) {
  148.                 set .@b,(.i[.b] * .r1 / 20) - mobcount(.c2$[.b],"invasor::Onm"+((.a * 3) - .@a)) + 10;
  149.                 if(.@b > 0) {
  150.                     if(.@b > .i[.b]) set .@b,.i[.b];
  151.                     monster .c2$[.b],0,0,"--ja--",getd(".m"+((.c * 12) + (.a * 3) - .@a)),.@b,"invasor::Onm"+((.a * 3) - .@a);
  152.                 }
  153.                 set .@a,.@a - 1;
  154.             }
  155.             set .@b,0;
  156.             sleep 30000;
  157.         }
  158.         set .d,0;
  159.         set .@a,10;
  160.         while(.@a) {
  161.             set .@a,.@a - 1;
  162.             killmonster .c2$[.b],"invasor::Onm"+.@a;
  163.         }
  164.         if(!.mf1) removemapflag .c2$[.b],1;
  165.         if(!.mf4) removemapflag .c2$[.b],4;
  166.         set .mf1,0;
  167.         set .mf4,0;
  168.         if(.a == -1) {
  169.             callsub Addmsg,"Base and Job experience rates are increased by "+.r2+"%. ("+.t4+" min)","ffaa00";
  170.             setbattleflag "base_exp_rate",getbattleflag("base_exp_rate") + set($TIbr,.r2);
  171.             setbattleflag "job_exp_rate",getbattleflag("job_exp_rate") + set($TIjr,.r3);
  172.             setcell "prontera",0,0,0,0,cell_water,1;
  173.             atcommand "@reloadmobdb";
  174.             sleep .t4 * 60 * 1000;
  175.             setbattleflag "base_exp_rate",getbattleflag("base_exp_rate") - .r2;
  176.             setbattleflag "job_exp_rate",getbattleflag("job_exp_rate") - .r3;
  177.             set $TIbr,0;
  178.             set $TIjr,0;
  179.             setcell "prontera",0,0,0,0,cell_water,0;
  180.             atcommand "@reloadmobdb";
  181.             announce "The experience rates has been restored.",bc_all,0xffaa00;
  182.         }
  183.     }
  184.     end;
  185.  
  186. Onc0:
  187.     if(getarg(2) > 0) {
  188.         set .c1$[.c],getarg(0);
  189.         set .c2$[.c],getarg(1);
  190.         set .i[.c],getarg(2);
  191.         set .c,.c + 1;
  192.     }
  193.     return;
  194.  
  195. Onc1:
  196.     set .@a,getarraysize(.n$);
  197.     set .n$[.@a],getarg(0);
  198.     while(.@b < 12) {
  199.         set getd(".m"+((.@a * 12) + .@b)),getarg(.@b + 1);
  200.         set .@b,.@b + 1;
  201.     }
  202.     return;
  203.  
  204. OnTimer:
  205.     sleep .t3 * 60 * 1000;
  206.     if(.a > 0) {
  207.         set .a,0;
  208.         awake "invasor";
  209.         callsub Clrmsg;
  210.         callsub Addmsg,"The defences in "+.c1$[.b]+" have been defeated by the invader armies.","ffaa00";
  211.         callsub Addmsg,"Today will be remembered as a black day for the server.","ffaa00";
  212.     }
  213.     end;
  214.  
  215. Onm0:
  216. OnM1:
  217. OnM2:
  218.     callsub Onms,1;
  219.  
  220. OnM3:
  221. OnM4:
  222. OnM5:
  223.     callsub Onms,2;
  224.  
  225. OnM6:
  226. OnM7:
  227. OnM8:
  228.     callsub Onms,3;
  229.  
  230. Onms:
  231.     if(playerattached() && .pcr1)
  232.         if(!rand((5 - getarg(0)) * 2500 / .pcr1)) getitem .pci,1;
  233.     end;
  234.  
  235. OnM9:
  236.     if(.a > 0) {
  237.         set .d,.d - 1;
  238.         if(.a != 3) {
  239.             setarray .@a$[0],"Sbirro","Hero";
  240.             set .@b$,callsub(Grammar_a_an,.n$[.c])+" "+.@a$[.a - 1];
  241.             if(playerattached()) {
  242.                 set .@c$,strcharinfo(0)+" has killed a"+.@b$+".";
  243.                 getitem .pci,(1 + .a) * 10 * .pcr2 / 100;
  244.             }
  245.             else set .@c$,"A"+.@b$+" has been killed.";
  246.             callsub Addmsg,.@c$+" ("+(4 - .a - .d)+"/"+(4 - .a)+")","ffaa00",.c2$[.b];
  247.             if(!.d) set .a,.a + 1;
  248.         }
  249.         else {
  250.             if(playerattached()) {
  251.                 set .@a$,strcharinfo(0)+" has killed the "+.n$[.c]+" Deux.";
  252.                 getitem .pci,60 * .pcr2 / 100;
  253.             }
  254.             else set .@a$,"The "+.n$[.c]+" Deux has been killed.";
  255.             callsub Addmsg,.@a$,"ffaa00",.c2$[.b];
  256.             callsub Addmsg,"The invader armies in "+.c1$[.b]+" has been defeated.","ffaa00";
  257.             if(.t4 && .r2) set .a,-1;
  258.             else set .a,0;
  259.             awake "invasor";
  260.         }
  261.     }
  262.     end;
  263.  
  264. OnPCLoginEvent:
  265.     if(.a > 0) {
  266.         sleep2 3000;
  267.         if(.a > 0) announce " S.O.S.!! "+.c1$[.b]+" is suffering from a terrible invasion.",bc_self,0xffaa00;
  268.     }
  269.     else if(.a == -1) {
  270.         sleep2 3000;
  271.         if(.a == -1) announce "Base and Job experience rates are increased by "+.r2+"%.",bc_self,0xffaa00;
  272.     }
  273.     end;
  274.  
  275. OnPCDieEvent:
  276.     if((.a > 0) && (getsavepoint(0) == .c2$[.b])) savepoint .s$,.sx,.sy;
  277.     end;
  278.  
  279. OnWhisperGlobal:
  280.     if(getgmlevel() >= .gm) {
  281.         set .@n$,"^008888The Invasor^000000";
  282.         mes .@n$;
  283.         mes "This is the Control Panel of The Invasor system.";
  284.         if(!.a) {
  285.             mes "Currently there isn't any invasion in progress.";
  286.             set .@t,$TIt - (gettimetick(2) / 60);
  287.             if(!.@t) set .@t$,"a few seconds";
  288.             else if(.@t < 60) set .@t$,.@t+" minutes";
  289.             else {
  290.                 set .@t,.@t / 60;
  291.                 if(.@t < 24) set .@t$,.@t+" hours";
  292.                 else set .@t$,(.@t / 24)+" days";
  293.             }
  294.             mes "Next automatic invasion event will take place in "+.@t$+".";
  295.             next;
  296.             set .@b,select("^880000Exit^000000","Start a new invasion.") - 1;
  297.             mes .@n$;
  298.             if(.@b) {
  299.                 mes "Select a city.";
  300.                 next;
  301.                 set .@a,select("^880000Random^000000",.c1$[0],.c1$[1],.c1$[2],.c1$[3],.c1$[4],.c1$[5],.c1$[6],.c1$[7],.c1$[8],.c1$[9],.c1$[10],.c1$[11],.c1$[12],.c1$[13],.c1$[14],.c1$[15],.c1$[16],.c1$[17],.c1$[18],.c1$[19],.c1$[20],.c1$[21],.c1$[22],.c1$[23],.c1$[24],.c1$[25],.c1$[26],.c1$[27],.c1$[28],.c1$[29],.c1$[30],.c1$[31],.c1$[32],.c1$[33],.c1$[34],.c1$[35],.c1$[36],.c1$[37],.c1$[38],.c1$[39]) - 1;
  302.                 mes .@n$;
  303.                 mes "Select a class for the invasion.";
  304.                 next;
  305.                 set .@b,select("^880000Random^000000",.n$[0],.n$[1],.n$[2],.n$[3],.n$[4],.n$[5],.n$[6],.n$[7],.n$[8],.n$[9],.n$[10],.n$[11],.n$[12],.n$[13],.n$[14],.n$[15],.n$[16],.n$[17],.n$[18],.n$[19],.n$[20],.n$[21],.n$[22],.n$[23],.n$[24]) - 1;
  306.                 mes .@n$;
  307.                 if(.a) {
  308.                     mes "Right now, you can't start a new invasion event.";
  309.                     mes "Come back in a while.";
  310.                     close;
  311.                 }
  312.                 set $TIt,0;
  313.                 set .b,.@a;
  314.                 set .c,.@b;
  315.                 awake "invasor";
  316.                 mes "A new invasion event has been started.";
  317.                 close;
  318.             }
  319.         }
  320.         else if(.a > 0) {
  321.             mes "Currently there is a"+callsub(Grammar_a_an,.n$[.c])+" invasion taking place in "+.c1$[.b]+".";
  322.             next;
  323.             set .@b,select("^880000Exit^000000","Cancel the current invasion.") - 1;
  324.             mes .@n$;
  325.             if(.@b) {
  326.                 if(.a < 1) {
  327.                     mes "Currently there isn't any invasion in progress.";
  328.                     close;
  329.                 }
  330.                 set .a,0;
  331.                 announce "The invasion in "+.c1$[.b]+" has been canceled.",bc_all,0xffaa00;
  332.                 mes "The invasion in "+.c1$[.b]+" has been canceled.";
  333.                 awake "invasor";
  334.                 close;
  335.             }
  336.         }
  337.         else {
  338.             mes "Base and Job experience rates are increased by "+.r2+"% as a reward for the previous invasion.";
  339.             next;
  340.             set .@b,select("^880000Exit^000000","Restore the experience rates.") - 1;
  341.             mes .@n$;
  342.             if(.@b) {
  343.                 if(.a != -1) {
  344.                     mes "Currently the experience rates aren't modified by The Invasor system.";
  345.                     close;
  346.                 }
  347.                 awake "invasor";
  348.                 mes "The experience rates has been restored.";
  349.                 close;
  350.             }
  351.         }
  352.         mes "See you soon.";
  353.         close;
  354.     }
  355.     end;
  356.  
  357. // Add a new message to the announcement list:
  358. // getarg(0): Message.
  359. // getarg(1): Color.
  360. // getarg(2): Map. (optional)
  361. Addmsg:
  362.     set .@a,getarraysize($@inv_msg0$);
  363.     if(.@a >= 10) {
  364.         deletearray $@inv_msg0$[0],.@a - 9;
  365.         set .@a,9;
  366.     }
  367.     set $@inv_msg0$[.@a],getarg(0);
  368.     set $@inv_msg1$[.@a],getarg(1);
  369.     set $@inv_msg2$[.@a],getarg(2,"");
  370.     if(!.@a) donpcevent "inv_msg::On0";
  371.     return;
  372.  
  373. // Clear the announcement list:
  374. Clrmsg:
  375.     set .@a,getarraysize($@inv_msg0$);
  376.     cleararray $@inv_msg0$[0],"",.@a;
  377.     cleararray $@inv_msg1$[0],"",.@a;
  378.     cleararray $@inv_msg2$[0],"",.@a;
  379.     awake "inv_msg";
  380.     return;
  381.  
  382. Grammar_a_an:
  383.     set .@w$," "+getarg(0);
  384.     setarray .@a$[0],"a","e","i","o","u","h";
  385.     set .@a,6;
  386.     while(.@a && !.@b) {
  387.         set .@a,.@a - 1;
  388.         set .@b,compare("_"+.@w$,"_ "+.@a$[.@a]);
  389.     }
  390.     if(.@b) set .@w$,"n"+.@w$;
  391.     return .@w$;
  392. }
  393.  
  394. // Delayed announcements:
  395. // Announces a message from the announcement list every 3 seconds.
  396. -   script  inv_msg -1,{
  397.  
  398. On0:
  399.     while(getarraysize($@inv_msg0$)) {
  400.         if($@inv_msg2$[0] == "") announce $@inv_msg0$[0],bc_all,"0x"+$@inv_msg1$[0];
  401.         else mapannounce $@inv_msg2$[0],$@inv_msg0$[0],bc_all,"0x"+$@inv_msg1$[0];
  402.         if(getarraysize($@inv_msg0$)) sleep 3000;
  403.         deletearray $@inv_msg0$[0],1;
  404.         deletearray $@inv_msg1$[0],1;
  405.         deletearray $@inv_msg2$[0],1;
  406.     }
  407.     end;
  408. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement