viewing paste Invasion NPC v2.1 | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
//===== eAthena Script ===========================================
//= Invasion NPC
//===== By: ======================================================
//= SketchyPhoenix
//===== Current Version: =========================================
//= 2.1
//===== Compatible With: =========================================
//= Anything revision not ancient :p
//===== Description: =============================================
//= Summons every MVP from a list at a random number on a random map.
//= There are 3 different types of spawns the invasion supports.
//===== Additional Comments: =====================================
//= 1.1 Added Invasion Control Panel
//= 1.1 Whisper to NPC:Invasion to access the Panel (lv 90 or higher GMs)
//= 1.2 Fixed a lot of variables (wrong scope)
//= 1.2 Cleared up some script errors | SonicR
//= 1.21 Fixed up all the errors I could find after a lot of testing
//= 1.21 added array population, event triggers in the panel
//= 1.22 Fixed the mob counting issue with invasion type 3
//= 1.23 Added a counter setting for invasions type 2 and 3.
//= 1.24 Fixed a variable typo for invasion types 2,3 causing unattached rid errors.
//= 1.3 Added a time setter (converted the custom WoE Setter to a function) /lazy on
//= 1.31 Added invasion type setting to timers and the menu returns to the beginning instead of closing
//= 2.1 Added an option to set and remove maps via panel
//===== Variable Explanations ====================================
//= $mvplist | All our MvPs and Mini Bosses are contained here.
//= .@mapname$ | Our list of potential invasion maps.
//= .@r | How many times should each monster spawn?
//= .clear | Is the event done?
//= $alteredlist | When you alter the array list, we dont want it to be overwritten.
//= .eventisoff | Prevents the event from starting (various reasons)
//= $invtype | Affects how the script spawns the monsters
//= .gmreq | Required GM level to use the panel.
//= .i_type2_count | Controls how many monsters spawn on invasion type 2
//= .i_type3_count | Same for type 3
//= $i_map$ | The map randomly chosen earlier is copied to a permanent var so that it can be used by the control panel 
//===================================================================
 
-   script  Invasion    -1,{
end;
 
OnInit:
 
    if (.i_type2_count==0) set .i_type2_count, 50; //Don't touch. Just defaults for how many monsters 
    if (.i_type3_count==0) set .i_type3_count, 50; //to spawn on invasions type 2 and 3 use the panel instead
    set .gmreq, 50;
    end;
    
OnMinute00:
// starting time check
    set $@num,0;
L_StartLoop:
    if($inv_sday[$@num] == 0 && $inv_eday[$@num] == 0 && $inv_time[$@num] == 0 && $inv_time2[$@num] == 0) goto L_StartLoopEnd;
    if(gettime(4)==$inv_sday[$@num] && gettime(3)>=$inv_time[$@num] && (gettime(3)<$inv_time2[$@num] || $inv_sday[$@num]!=$inv_eday[$@num])) goto L_Start;
    set $@num,$@num+1;
    goto L_StartLoop;
 
// end time checks
    L_StartLoopEnd:
    set $@num,0;
    L_EndLoop:
    if($inv_eday[$@num] == 0 && $inv_time[$@num] == 0 && $inv_time2[$@num] == 0) end;
    if((gettime(4)==$inv_eday[$@num]) && (gettime(3)==$inv_time2[$@num])) goto L_End;
    set $@num,$@num+1;
    goto L_EndLoop;
    end;
    
 
L_Start:
 
    if (.clear == 1 || agitcheck() == 1 || .eventisoff == 1) end;
 
    if ($alteredlist == 0) {
    setarray $mvplist[0],1511,1647,1785,1630,1039,1399,1874,1272,1719,1046,1389,1112,1115,1418,1871,1252,1768,1086,1885,1649,1651,1832,1492,1734,1251,1779,1688,1646,1373,1147,1059,1150,1087,1190,1038,1157,1159,1502,1623,1650,1583,1708,1312,1751,1685,1648,1658,1219,1275,1096,1388,1268,1250,1283,1270,1302,1108,1582,1091,1093,1205,1120,1299,1259,1376,1296,1090,1289,1313,1262,1203,1204,1308,1065,1089,1618,1092,1088,1200;
    setarray $mapname$[0],"prontera","izlude","geffen","morocc";
    }
 
L_Event:
    set .@m, rand(0,getarraysize($mapname$));
    if (.@m == getarraysize($mapname$)) set .@m, .@m-1; //Simply putting a -1 in the line abouve didn't seem to work so I just used this.
    set $i_map$, $mapname$[.@m]; //For Panel
    set .mobcount, 0;
    set .totalkills, 0;
    set .@mcount, 0;
    if ($inv_timetype[.@num] == 2) goto L_Type2;
    if ($inv_timetype[.@num] == 3 || $inv_timetype[.@num] == 0) goto L_Type3;
L_Type1:
    if ($invtype == 1) {
        for(set .@i,0; .@i < getarraysize($mvplist) ; set .@i,.@i+1)
        {
            set .@r, rand(1,3);
            monster $mapname$[.@m],0,0,""+getmonsterinfo($mvplist[.@i],0)+"",$mvplist[.@i],.@r,"Invasion::OnInvasion";
            set .mobcount, .mobcount+.@r;
        }
    }
L_Type2:
    if ($invtype == 2) {
        for(set .@b,0; .@b < .i_type2_count ; set .@b,.@b+1)
        {
            set .@r, rand(1,3);
            monster $mapname$[.@m],0,0,"Enslaved Minion",-1,.@r,"Invasion::OnInvasion";
            set .mobcount, .mobcount+.@r;
        }
    }
L_Type3:
    if ($invtype == 3 || $invtype == 0) {
        for(set .@c,0; .@c < .i_type3_count ; set .@c,.@c+1)
        {
            set .@r, rand(1,3);
            if (.@mcount == 10) {
                set .@mr, rand(0,getarraysize($mvplist)-1);
                monster $mapname$[.@m],0,0,""+getmonsterinfo($mvplist[.@mr],0)+"",$mvplist[.@mr],.@r,"Invasion::OnInvasion";
                set .mobcount, .mobcount+.@r;
                set .@mcount, 0;
            }
            monster $mapname$[.@m],0,0,"Enslaved Minion",-1,.@r,"Invasion::OnInvasion";
            set .mobcount, .mobcount+.@r;
            set .@mcount, .@mcount+1;
        }
    }
    announce "Look out! Monsters are invading!! ("+$mapname$[.@m]+")",0;
    set .clear, 1;
    end;
 
OnWhisperGlobal:
    if(getgmlevel() < .gmreq || @whispervar0$ != "Panel") end;
    mes "[Invasion NPC Control Panel]";
    mes "Current List of Monsters Spawned by the Invasion Array.";
    next;
    set .@jl, 0;
    for(set .@j,0; .@j < getarraysize($mvplist) ; set .@j,.@j+1)
    {
        set .@jl,.@j+1;
        mes "["+.@jl+"]. "+getmonsterinfo($mvplist[.@j],0)+",";
    }
    next;
    mes "[Invasion NPC Control Panel]";
L_PanelMenu:
    mes "What action would you like to take?";
    switch(select("Populate Arrays","Add a monster","Remove a monster","Add a map","Remove a map","Set Invasion Count","Set Invasion Type","Disable Events","Trigger Event","Cancel Event","Set Invasion Times")) {
 
    case 1:
        next;
        setarray $mvplist[0],1511,1647,1785,1630,1039,1399,1874,1272,1719,1046,1389,1112,1115,1418,1871,1252,1768,1086,1885,1649,1651,1832,1492,1734,1251,1779,1688,1646,1373,1147,1059,1150,1087,1190,1038,1157,1159,1502,1623,1650,1583,1708,1312,1751,1685,1648,1658,1219,1275,1096,1388,1268,1250,1283,1270,1302,1108,1582,1091,1093,1205,1120,1299,1259,1376,1296,1090,1289,1313,1262,1203,1204,1308,1065,1089,1618,1092,1088,1200;
        setarray $mapname$[0],"prontera","izlude","geffen","morocc";
        mes "[Invasion NPC Control Panel]";
        mes "Arrays populated!";
        next;;
        goto L_PanelMenu;
 
    case 2:
        next;
        if (getarraysize($mvplist) == 128) {
            mes "[Invasion NPC Control Panel]";
            mes "The list of MVPs is full!";
            mes "Please delete an MVP from the list first.";
            close;
        }
        mes "[Invasion NPC Control Panel]";
        mes "Add the monster's ^0000ffID^000000 to the list.";
        mes "0 = cancel.";
        input @mobid;
        next;
        if (@mobid <= 0 || getmonsterinfo(@mobid,1) == -1) {
            mes "[Invasion NPC Control Panel]";
            mes "Invalid monster or user-cancelled!";
            close;
        }
        setarray $mvplist[getarraysize($mvplist)],@mobid;
        mes "[Invasion NPC Control Panel]";
        mes "The monster, "+getmonsterinfo(@mobid,0)+", has been added to the list!";
        set $alteredlist, 1;
        next;
        goto L_PanelMenu;
 
    case 3:
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Which monster would you like to delete from the list?";
        mes "(No. on the list | 0 to cancel)";
        input @l;
        if (@l <= 0) {
            mes "[Invasion NPC Control Panel]";
            mes "Invalid Entry!";
            close;
        } //Have to seperate these checks otherwise there's an error | -1 isn't an index :{
        set @l, @l-1;
        if (getmonsterinfo($mvplist[@l],1) == -1) {
            next;
            mes "[Invasion NPC Control Panel]";
            mes "Invalid Entry!";
            close;
        }
        next;
        mes "[Invasion NPC Control Panel]";
        mes "You have deleted monster, "+getmonsterinfo($mvplist[@l],0)+", from the list!";
        deletearray $mvplist[@l],1;
        set $alteredlist, 1;
        next;
        goto L_PanelMenu;
        
    case 4:
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Current List of maps used by the Invasion Array.";
        next;
        set .@mnl, 0;
        for(set .@p,0; .@p < getarraysize($mapname$) ; set .@p,.@p+1)
        {
            set .@mnl,.@p+1;
            mes "["+.@mnl+"]. "+$mapname$[.@p]+",";
        }
        next;   
        if (getarraysize($mapname$) == 128) {
            mes "[Invasion NPC Control Panel]";
            mes "The list of maps is full!";
            mes "Please delete a map from the list first.";
            close;
        }
        mes "[Invasion NPC Control Panel]";
        mes "Add the map to the list.";
        mes "0 = cancel.";
        input @mapname$;
        next;
        if (@mapname$ == "0" || getmapmobs(@mapname$) == -1) {
            mes "[Invasion NPC Control Panel]";
            mes "Invalid map or user-cancelled!";
            close;
        }
        setarray $mapname$[getarraysize($mapname$)],@mapname$;
        mes "[Invasion NPC Control Panel]";
        mes "The map, "+@mapname$+", has been added to the list!";
        set $alteredlist, 1;
        next;
        goto L_PanelMenu;
        
    case 5:
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Current List of maps used by the Invasion Array.";
        next;
        set .@mnl, 0;
        for(set .@p,0; .@p < getarraysize($mapname$) ; set .@p,.@p+1)
        {
            set .@mnl,.@p+1;
            mes "["+.@mnl+"]. "+$mapname$[.@p]+",";
        }
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Which map would you like to delete from the list?";
        mes "(No. on the list | 0 to cancel)";
        input @map$;
        if (@map$ == "0") {
            mes "[Invasion NPC Control Panel]";
            mes "Cancelled!";
            next;
            goto L_PanelMenu;
        }
        for (set @b,0; @b < getarraysize($mapname$) ; set @b, @b+1) {
            if ($mapname$[@b] == @map$) {
            next;
            mes "[Invasion NPC Control Panel]";
            mes "You have deleted map, "+$mapname$[@b]+", from the list!";
            deletearray $mapname$[@b],1;
            set $alteredlist, 1;
            next;
            goto L_PanelMenu;
            }
        }
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Map not found!";
        next;
        goto L_PanelMenu;
        
    case 6:
        mes "[Invasion NPC Control Panel]";
        mes "Input the amount of monsters to spawn for invasion type 2. ( 0 to cancel/skip to type 3 )";
        input .@i_type2_count;
        if (.@i_type2_count < 1) {
            mes "Invasion Type 2 skipped.";
        }
        else if (.@i_type2_count > 0) {
            set .i_type2_count, .@i_type2_count;
            mes "Type 2 will now spawn "+.i_type2_count+" monsters.";
        }
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Input the amount of monsters to spawn for invasion type 3. ( 0 to cancel )";
        input .@i_type3_count;
        if (.@i_type3_count < 1) {
            mes "Invasion Type 3 skipped.";
        }
        else if (.@i_type3_count > 0) {
            set .i_type3_count, .@i_type3_count;
            mes "Type 3 will now spawn "+.i_type3_count+" monsters.";
        }
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Thank you for using the Invasion Panel!";
        next;
        goto L_PanelMenu;
 
    case 7:
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Invasion Types:";
        mes "1 - Only monsters from the Invasion Array will spawn.";
        mes "2 - Only Dead Branch / Bloody Branch monsters will spawn.";
        mes "3 - Spawns 1 Invasion Array monster for every 10 DB/BB monsters spawned.";
        next;
        mes "[Invasion NPC Control Panel]";
        mes "Which one do you want?";
        mes "(Number of Invasion type. 0 to cancel)";
        input $invtype;
        next;
        if ($invtype <= 0 || $invtype >= 4) {
            mes "[Invasion NPC Control Panel]";
            mes "Invalid number or cancelled!";
            close;
        }
        mes "[Invasion NPC Control Panel]";
        mes "Invasion style "+$invtype+" set!";
        next;
        goto L_PanelMenu;
 
    case 8:
        next;
        if (.eventisoff == 0) {
            mes "[Invasion NPC Control Panel]";
            mes "The Invasion events will cease to run until the NPC is reloaded or is set back on.";
            set .eventisoff, 1;
            close;
        }
        mes "[Invasion NPC Control Panel]";
        mes "The Invasion events will continue as scheduled.";
        set .eventisoff, 0;
        next;
        goto L_PanelMenu;
 
    case 9:
        mes "[Invasion NPC Control Panel]";
        mes "Now triggering event...";
        close2;
        goto L_Event;
 
    case 10:
        killmonster $i_map$,"Invasion::OnInvasion";
        announce "The Invasion Event has been cancelled!",0;
        set .clear, 0;
        next;
        goto L_PanelMenu;
    
    case 11:
        callfunc "inv_setter";
        next;
        goto L_PanelMenu;
        
    case 12:
        mes "[Invasion NPC Control Panel]";
        mes "Thank you for using Phoenix Invasion.";
        close;
    }
    
L_End:
    if (.clear == 1) {
        killmonster $i_map$,"Invasion::OnInvasion";
        announce "Time has run out! The Invasion has ended!",0;
        set .clear, 0;
        end;
    }
    
OnInvasion:
    set .totalkills, .totalkills+1;
    if (.totalkills >= .mobcount) {
        set .clear, 0;
        announce "Congratulations, the invasion was stopped!",0;
        end;
    }
    end;
 
OnAgitStart:
    if (.clear == 1) {
        killmonster $i_map$,"Invasion::OnInvasion";
        announce "WoE has begun, the Invasion event has ended!",0;
        set .clear, 0;
        end;
    }
}
 
function    script  inv_setter  {
    mes "[Invasion NPC Control Panel]";
    mes "Please use this menu to control Invasion Times.";
    mes "Simply follow the intruction given in each section after this, and it should be set and ready to use";
    menu "Add an Invasion time",L_Add,"Reset all Invasion times.",L_Reset,"View Current Invasion times",-;
    mes "[Invasion NPC Control Panel]";
    mes "Current Invasion times are set for...:-";
    set .@num,0;
L_LoopList:
    if($inv_sday[.@num] == 0 && $inv_eday[.@num] == 0 && $inv_time[.@num] == 0 && $inv_time2[.@num] == 0) goto L_LoopListEnd;
    if($inv_sday[.@num]==0) set $@inv_tempday$,"Sunday";
    if($inv_sday[.@num]==1) set $@inv_tempday$,"Monday";
    if($inv_sday[.@num]==2) set $@inv_tempday$,"Tuesday";
    if($inv_sday[.@num]==3) set $@inv_tempday$,"Wednesday";
    if($inv_sday[.@num]==4) set $@inv_tempday$,"Thursday";
    if($inv_sday[.@num]==5) set $@inv_tempday$,"Friday";
    if($inv_sday[.@num]==6) set $@inv_tempday$,"Saturday";
    if($inv_eday[.@num]==0) set $@inv_tempday2$,"Sunday";
    if($inv_eday[.@num]==1) set $@inv_tempday2$,"Monday";
    if($inv_eday[.@num]==2) set $@inv_tempday2$,"Tuesday";
    if($inv_eday[.@num]==3) set $@inv_tempday2$,"Wednesday";
    if($inv_eday[.@num]==4) set $@inv_tempday2$,"Thursday";
    if($inv_eday[.@num]==5) set $@inv_tempday2$,"Friday";
    if($inv_eday[.@num]==6) set $@inv_tempday2$,"Saturday";
    if($inv_eday[.@num]==$inv_sday[.@num]) mes $@inv_tempday$+" from "+$inv_time[.@num]+":00 till "+$inv_time2[.@num]+":00 : Type "+$inv_timetype[.@num];
    if($inv_eday[.@num]!=$inv_sday[.@num]) mes "From "+$@inv_tempday$+" "+$inv_time[.@num]+":00 till "+$@inv_tempday2$+" "+$inv_time2[.@num]+":00 : Type "+$inv_timetype[.@num];
    set .@num,.@num+1;
    goto L_LoopList;
L_LoopListEnd:
    return;
L_Add:
    set .@num,0;
L_AddLoop:
    if($inv_sday[.@num] == 0 && $inv_eday[.@num] == 0 && $inv_time[.@num] == 0 && $inv_time2[.@num] == 0) goto L_AddLoopEnd;
    set .@num,.@num+1;
    goto L_AddLoop;
L_AddLoopEnd: 
    mes "[Invasion NPC Control Panel]";
    mes "What day do you want the Invasion to start ^FF0000start^000000 in?";
    next;
    menu "Sunday",-,"Monday",-,"Tuesday",-,"Wednesday",-,"Thursday",-,"Friday",-,"Saturday",-;
    if(@menu==1) set $inv_sday[.@num],0;
    if(@menu==2) set $inv_sday[.@num],1;
    if(@menu==3) set $inv_sday[.@num],2;
    if(@menu==4) set $inv_sday[.@num],3;
    if(@menu==5) set $inv_sday[.@num],4;
    if(@menu==6) set $inv_sday[.@num],5;
    if(@menu==7) set $inv_sday[.@num],6;
    mes "[Invasion NPC Control Panel]";
    mes "Ok, now please enter the hour you want the Invasion to ^FF0000start^000000 at";
    mes "This is using a 24 hour clock";
    mes "00 = Midnight";
    mes "12 = Mid-day";
    mes "23 = 11pm";
    next;
    input .@input;
    if (.@input < 0 || .@input > 24) goto L_BadNumber;
    set $inv_time[.@num],.@input;
    mes "[Invasion NPC Control Panel]";
    mes "What day do you want the Invasion to start ^FF0000finish^000000 in?";
    next;
    menu "Same as start",-,"Sunday",-,"Monday",-,"Tuesday",-,"Wednesday",-,"Thursday",-,"Friday",-,"Saturday",-;
    if(@menu==1) set $inv_eday[.@num],$inv_sday[@num];
    if(@menu==2) set $inv_eday[.@num],0;
    if(@menu==3) set $inv_eday[.@num],1;
    if(@menu==4) set $inv_eday[.@num],2;
    if(@menu==5) set $inv_eday[.@num],3;
    if(@menu==6) set $inv_eday[.@num],4;
    if(@menu==7) set $inv_eday[.@num],5;
    if(@menu==8) set $inv_eday[.@num],6;
    mes "[Invasion NPC Control Panel]";
    mes "Ok, now please enter the hour you want the Invasion to ^FF0000finish^000000 at";
    mes "This also uses the 24 hour clock";
    mes "00 = Midnight";
    mes "12 = Mid-day";
    mes "23 = 11pm";
    next;
    input .@input;
    if (.@input < 0 || .@input > 24) goto L_BadNumber;
    set $inv_time2[.@num],.@input;
    mes "[Invasion NPC Control Panel]";
    mes "Set the Invasion Type for this time.";
    input .@input;
    if (.@input < 1 || .@input > 3) goto L_BadNumber;
    set $inv_timetype[.@num],.@input;
    mes "Your Invasion time has now been set";
    mes "To confirm this, ask me to show you the ^FF0000'Current Invasion times'^000000";
    return;
L_Reset:
    mes "[Invasion NPC Control Panel]";
    mes "You are about to reset all the set Invasion times you have created";
    mes "Are you sure?";
    next;
    menu "No, what was I thinking",L_No,"Yes I really want to do it",-;
    if(.clear == 1) goto L_InvOn;
    deletearray $inv_sday[0],200;
    deletearray $inv_eday[0],200;
    deletearray $inv_time[0],200;
    deletearray $inv_time2[0],200
    mes "[Invasion NPC Control Panel]";
    mes "They are all gone now, please remember to set new ones";
    return;
L_InvOn:
    mes "[Invasion NPC Control Panel]";
    mes "Sorry, since there is a Invasion in progress you cannot reset the Invasion times";
    return;
L_No:
    mes "[Invasion NPC Control Panel]";
    mes "Oh, good, come back whenever";
    return;
L_BadNumber:
    mes "[Invasion NPC Control Panel]";
    mes "Sorry that was an invalid number, please try again";
    return;
}
 
//Blacklist :: The following servers are prohibited from using this script
//AkinaRO
Viewed 794 times, submitted by Guest.