Jump to content

Chris' Script Collection [Last Update: 04-06/2021]


llchrisll

Recommended Posts


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

On 8/2/2020 at 3:58 AM, kevinyrchua said:

Are you referring to john at prt_fild08?, I have spawned him already and can talk to him but no options available.. is there something i need to setup through the script or through the npc? 

Well just a small issue regarding getmapxy, since I didn't update it since they changed the it was handled, it errors ofc.
For a quick fix, just exchange the "1" at the end of every getmapxy to BL_NPC and you are fine.
 

Edit: Updated some scripts along with the fix of it.

Edited by llchrisll
Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   2
  • Joined:  07/11/13
  • Last Seen:  

Hey Chris,

thank you for your amazing scripts.

I'm encountering a problem with your arena master script :

 

[Warning]: script:getelementofarray: index out of range (-4)
[Debug]: Data: variable name='$@sphree_names$' index=0
[Debug]: Source (NPC): Arena Master at prontera (164,163)

I also noticed that Kills aren't updated in sql db while everything else seem to work fine.

Thank you

Link to comment
Share on other sites

  • 4 weeks later...

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  08/13/18
  • Last Seen:  

On 23/08/2019 at 11:20, Tiki59 said:

llchrisll ,

Testei sua Battle Ground Arena e ocorreu um erro ao usar o comando @startbgarena.

THX.

 

 

erreurbg1.png

erreurbg2.png

infelizmente estou com mesmo problema !

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

I'm aware that it's erroring, but I'm too lazy atm trying to fix it.
Also english please next time ^^.
(I guessed from your map server console, btw what you wanna tell me)

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.01
  • Content Count:  35
  • Reputation:   1
  • Joined:  10/22/20
  • Last Seen:  

Hi Chris i have issue using your mob invasion

Setting is on Single map,item reward per kill using the npc,


my issues when i used it is.

1. mobs doesn't spawn in one go, seems like it is by batches .

2. it only announces mob remaining when it is only 5 (want it to announce it through all out of the event)

3. doesnt forcibly ends after 3600

4. need the event to be all normal attacks, skill will be disabled on the spam of the event.

i hope you can help me
 

//===== rAthena Script =======================================
//= Monster Invasion
//===== By ===================================================
//= llchrisll
//===== Version ==============================================
//= 1.0 - Initial Release
//  1.1 - Added custom Commands for GM's to start/end the invasion manually.
//      - Exchanged the Custom Variable Settings for the Reward NPC with
//        the forgotten Cash Points reward (ups..)
//      - Removed the idea about using an Invasion Shop
//      - Fixed reward announcer to display correct lines
//===== Tested With ==========================================
//= rAthena 04/26/2019 Revision
//= GIT Hash: 67e1583f9fec7ac95a954634f6b7600ebe428df0
//===== Description ==========================================
//= There are 2 Invasion Types:
//  - Single
//  - Multiply
//= Each can be seperatly customized, but can not be switched via ingame.
//= Changing settings means to restart/reload the server for them to become active
//= Also there is an "Invasion Rewarder" available after the Invasion,
//  which can be turned on or off
//  To change the reward itself, scroll down to the bottom of the file
//  where the NPC is located. There are extra settings.
//= See "OnInit:" for the main settings
//===== Comments =============================================
//= None yet... 
//===========================================================
-    script    MobInvaInit    -1,{
function    DELAY;

OnTimer1000: // Every Second
stopnpctimer;
set .s,.s + 1;
if(.debug) 
    // Showing Debug every minute only.
    if(.s%60 == 0) debugmes .n$+": Delay Timer: "+.s+" seconds (Minutes: "+(.s/60)+"), Delay Function returns: "+DELAY(.delay_type,.delay_pos,1)+", Invasion Re-/Starts: "+.time[.delay_pos]+" (in seconds), Force End: "+.inva_fend+" (in seconds)";
if(.delay == 1 && .s == DELAY(.delay_type,.delay_pos,1) ) 
    donpcevent strnpcinfo(0)+"::OnInvaInit";
else if( .s == .inva_fend && .inva_status) 
    donpcevent strnpcinfo(0)+"::OnInvaForceEnd";
initnpctimer;
end;


OnClock1300: // 1 p.m.
OnClock2000:
if(.delay == 1) // Delay Usage active
    end;
    
OnInvaInit:
if(.inva_status) end;

if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    disablenpc "Invasion Rewarder";

switch(.inva_type) {
    
    // Single Town Invasion
    case 1:
    if(!.s_inva_spec) { // No Map Specification > Random
    
        if(rand(1,10) <= 5) { // 50% chance to use either a big city or a small one
            set .t,rand(getarraysize(.map_b$));
            set .map_use,1; // Use big Maps
        } else {
            set .t,rand(getarraysize(.map_s$));
            set .map_use,2; // Use small Maps
        }
    } else {
        set .map_use,.s_inva_spec;
        set .t,.s_inva_pos;
    }
    if(.map_use == 1) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.t])); set .@m,.@m + 1) {
            monster .map_b$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_b$);
        }
        announce .n$+": The town "+.map_b$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    
    } else if(.map_use == 2) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.t])); set .@m,.@m + 1) {
            monster .map_s$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_s$);
        }
        announce .n$+": The town "+.map_s$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    }
    break;
    
    // Multiply Town Invasion
    case 2:
    if( .inva_spawn == 1) {
        for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
            }
            announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
        
        sleep 500;
        
        for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
            }
            announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
    // * Spawn Option - Specific Maps
    } else if( .inva_spawn == 2) {
        
        set .@map_am,.inva_maps; // Copying Map Quantity
        
        if(.debug)
            debugmes .n$+": Map Quantity - .inva_maps: "+.inva_maps+" > .@map_am";
        // * Map Size - Big Maps 
        if( .inva_size == 1) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_b$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_b$);
                
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
                
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: Yes";
                    
                while ( .@c < .@map_am ) {
                    if(.debug) 
                        debugmes .n$+": Big Maps - Counter: "+.@c+", Map Index: "+.@t;
                
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if((.@t+1) == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],(.@t+1); // Copying already use maps.
                    set .@c,.@c + 1;
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .@map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
            
        // * Map Size - Small Maps 
        } else if( .inva_size == 2) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_s$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_s$);
            
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
            
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
                while ( .@c < .@map_am ) {
                    
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if(.@t == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],.@t; // Copying already use maps.
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
                
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
        }
    }
    break;
    
}
set .inva_status,1;
end;


OnMobSingleKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set .MobSKilled,.MobSKilled - 1;
switch(.MobSKilled) {
    case 0:
    announce .n$+": Congratulation to ["+strcharinfo(0)+"] who delivered the final blow!!! Nicely Done!!!",0;
    if(.inva_final) {
        announce .n$+": You also get an \"Final Kill Reward\", just take a look in the Chat Box. See ya next time *g*",bc_self;
        dispbottom .n$+": You have been rewarded with:";
        if(.inva_f_id == 1) {
            set Zeny,Zeny + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Zeny.";
        } else if(.inva_f_id == 2) {
            set #CASHPOINTS,#CASHPOINTS + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Cash Points. New Balance is "+#CASHPOINTS+".";
        } else if(.inva_f_id >= 512) {
            getitem .inva_f_id,.inva_f_am;
            dispbottom .n$+": "+.inva_f_am+"x "+getitemname(.inva_f_id)+".";
        }
    }
    sleep 10000;
    donpcevent strnpcinfo(0)+"::OnInvaEnd";
    break;
    
    case 1:
    mapannounce strcharinfo(3),.n$+": JUST "+.MobSKilled+" MONSTER is left!!!! FINAL BLOW, GO GO!!!",bc_yellow;
    break;
    
    case 2:
    case 3:
    case 4:
    mapannounce strcharinfo(3),.n$+": Only "+.MobSKilled+" monsters are left!!!! We can do it!!!",bc_yellow;
    break;

    case 5:
    mapannounce strcharinfo(3),.n$+": LAST "+.MobSKilled+"!!!! We can do it!!!",bc_yellow;
    break;
    
    default: break;
}
end;

OnMobMultiKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0)
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set @loc,0;
for ( set .@l,0; .@l < getarraysize(.map_b$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_b$[.@l]) {
        set @loc,1;
        set @map,.@l;
        break;
    }
    
for ( set .@l,0; .@l < getarraysize(.map_s$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_s$[.@l]) {
        set @loc,2;
        set @map,.@l;
        break;
    }

OnMMobKilled:
if(.debug) 
    debugmes .n$+": 2nd Loc Check: @Loc; "+@loc+", @map: "+@map;
switch( @loc ) {
    
    case 1: 
    setd(".Mob_"+.map_post_b$[@map]+"_Killed"),getd(".Mob_"+.map_post_b$[@map]+"_Killed") - 1; 
    if(.debug)
        debugmes .n$+": Mobs: "+mobcount(.map_b$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_b$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_b$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_b$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
    
    case 2: 
    setd(".Mob_"+.map_post_s$[@map]+"_Killed"),getd(".Mob_"+.map_post_s$[@map]+"_Killed") - 1; 
    if(.debug) 
        debugmes .n$+": Mobs: "+mobcount(.map_s$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_s$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_s$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_s$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
}
end;

OnOtherTown:
for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
        set .@mapb_left$,.@mapb_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");

for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
        set .@maps_left$,.@maps_left$ + .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");

if(.@maps_left$ == "" && .@mapb_left$ == "")
    donpcevent strnpcinfo(0)+"::OnInvaEnd";

announce .n$+": In the "+ ( (.@mapb_left$ != "")?"big towns "+.@mapb_left$+ ( (.@maps_left$ != "")?" and small towns "+.@maps_left$:""):"small towns "+.@maps_left$)+" are still Monsters, please help use to defeat them!!!",0;
end;

OnInvaEnd:
announce .n$+": Thank you guys for your help in defeating the invaders, we will counting on you for the next time as well.",0;
donpcevent strnpcinfo(0)+"::OnInvaRestart";
end;

OnInvaForceEnd:
announce .n$+": NOOOOO!!! The monsters successfully invaded the towns, RETREAT GUARDS!!!",0;
sleep 10000;
announce .n$+": Brave Fighters, I thank you for your support, but we failed!!",0;
sleep 10000;
announce .n$+": Let's regroup and let's try again, I will inform you when we are ready!!",0;

OnInvaRestart:
DELAY(.delay_type,.delay_pos,2);
// Removing Mobs which kinda survived
if(.inva_type == 1) // Single Town
    if(.map_use == 1) killmonster .map_b$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    else killmonster .map_s$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    
else if(.inva_type == 2) { // Multi Town
    for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
        killmonster .map_b$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
        
    for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1)
        killmonster .map_s$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
    }
set .inva_status,0;
if(.delay == 1) set .s,0; // Reseting Delay Counter
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) {
    enablenpc "Invasion Rewarder";
    announce .n$+": Visit the \"Invasion Rewarder\" to recieve rewards for your kills. But hurry, he will disappear in "+getvariableofnpc(.rew_dis,"Invasion Rewarder")+" minutes.",0;
    donpcevent strnpcinfo(0)+"::OnRewardDisable";
}
end;

// Auto Disable Reward NPC
OnRewardDisable:
set .m,getvariableofnpc(.rew_dis,"Invasion Rewarder");
while( .m != 0 ) {
    switch(.m) {
        case 4: 
        case 3:
        case 2:
        announce .n$+": The \"Invasion Rewarder\" will disappear in "+.m+" minutes.",bc_all; break;
        case 1: announce .n$+": HURRY, the \"Invasion Rewarder\" will disappear in 1 minute.",bc_all; break;
    }
    set .m,.m - 1;
    sleep 60000;
}        
announce "Invasion Rewarder: Okay, I'm done here. See ya next time!!!",0;
set .m,0;
disablenpc "Invasion Rewarder";
end;

OnPCLoginEvent:
if(.inva_status == 0) end;
announce .n$+": The Monster Invasion Event is currently running, please hurry and help us!!",bc_self;
sleep2 2000;
if(.inva_type == 1) 
    set .@map_left$,( (.map_use == 1) ? .map_b$[.t]:.map_s$[.t]);
else if(.inva_type == 2) {
    for ( set .@m,0; .@m < getarraysize(.map_b$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");
            
    for ( set .@m,0; .@m < getarraysize(.map_s$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ +" and "+ .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");
}
announce .n$+": We are defending at "+ .@map_left$+"!!!",bc_self;
end;

OnInit:
set .n$,"[Ragnarok Guard]";
// Debug Mode - See Map Server Console for Debug messages
set .debug,0;
// ======= Invasion Type =======
// - 1: Single
// - 2: Multiply
set .inva_type,1;
// ====== Single Invasion Settings =========
if(.inva_type == 1) {
    // * Specific Map Usage
    // - 0 = Random
    // - 1 = Big Maps
    // - 2 = Small Maps
    set .s_inva_spec,0;

    if(.s_inva_spec > 0) {
        // * Map Index
        // X = Array Index of the Map Array
        set .s_inva_pos,0;
    }
// ======= Multiply Invasion Settings ========
} else if(.inva_type == 2) {
    // * Spawn Option
    // - 1: All Maps
    // - 2: Specific Maps
    set .inva_spawn,2;

    if(.inva_spawn == 2) {
        // * Map Usage:
        // - 1: Big Maps
        // - 2: Small Maps
        set .inva_size,1;
        
        // * Map Amount:
        // - 0: All Maps from .inva_size above
        // - 1+: ...
        // Note: If this value exceeds the size of the map array, 
        // then it will use all maps of .inva_size.
        set .inva_maps,0;
 
        if(.inva_maps > 0 && .inva_maps < ( (.inva_size == 1)?getarraysize(.map_b$):getarraysize(.map_s$) ) ) 
        // * Map Randoming:
        // - 0: No
        // - 1: Yes
        // Note: Map Randoming is only possible when not all maps are wanted
        // It would be ineffective to make map randoming when there are all maps active :I
        set .inva_rand,1;
    }
}
// * Invasion on Server Start
// - 0: No
// - 1: Yes
set .inva_statusinit,0;
// * Invasion Force End
// - 0: Not used
// - 1+: ...
// Note: The Event will automatically end after this value has passed (in seconds)
set .inva_fend,3600; // 1 Hour
// =======*======= DELAY SETTINGS =======*=======
// * Delay Usage
// - 0: Off - OnClockXXXX will be used
// - 1: On
set .delay,0;
// * Delay Type
// - 1: Random (Default)
// - 2: Fixed Delay
// - 3: Ranged Delay
set .delay_type,1;

// ---- Fixed Delay ----
// Array Position in ".time"
if(.delay_type == 2) 
    set .delay_pos,0;
// ---- Ranged Delay ----
// Array Position for start index
if(.delay_type == 3) 
    set .delay_pos,3;

// * Delay Times
setarray .time[0],
// In Seconds  -  is equal to  -  Array Position
        10800, // 3 Hours      -  0
        14400, // 4 Hours      -  1
        21600, // 6 Hours      -  2
        86400, // 1 Day        -  3
        172800, // 2 Days      -  4    
        259200; // 3 Days      -  5

// =======*======= MONSTER SETTINGS =======*=======
// * Mob Quantity Limit depending on the map size
// - Big Maps
set .m_limit_b,100;
// - Small Maps
set .m_limit_s,30;

// * Maps List
// - Big Maps 
setarray .map_b$[0],"prontera","geffen","payon","morocc","aldebaran","alberta";
// For every map you have to add an postfix in the same order,
// which has been put in the array for the Maps
// After this, just set an array with the Mob IDs where the
// array name contains the postfix you set-up, see the examples
setarray .map_post_b$[0],"pron","gef","pay","mor","alde","alb";
// - Small Maps
setarray .map_s$[0],"izlude";
setarray .map_post_s$[0],"izl";
// ======= Monster ID's =======
// ------ Big Maps ------
// * Prontera - Mantis, Thief Bug Male, Argos, Side Winder
setarray .mob_pron[0],1139,1054,1100,1037;
// * Geffen - Poison Spore, Ghoul, Jakk, High Orc
setarray .mob_gef[0],1855,1036,1130,1213;
// * Payon - Zombie, Elder Willow, Munak, Nine Tail, Drainliar
setarray .mob_pay[0],1015,1033,1026,1180,1111;
// * Morocc - Requiem, Isis, Mummy, Minorous
setarray .mob_mor[0],1164,1029,1041,1149;
// * Aldebaran - Cramp, Penomena, Punk, Orc Archer, Bathory
setarray .mob_alde[0],1209,1029,1199,1189,1102;
// * Alberta - Pirate Skeleton, Penomena, Poison Spore, Whisper, Mimic
setarray .mob_alb[0],1071,1029,1077,1179,1191;
// ------ Small Maps ------
// * Izlude - Obeaune, Merman, Swordfish, Strouf
setarray .mob_izl[0],1044,1264,1069,1065;

// ------ Mob Amount Calculation for Big Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_b$); set .@c,.@c + 1) 
    setd(".mam_"+.map_post_b$[.@c]),( .m_limit_b/getarraysize(getd(".mob_"+.map_post_b$)) );
    
// ------ Mob Amount Calculation for Small Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_s$); set .@c,.@c + 1)
    setd(".mam_"+.map_post_s$[.@c]),( .m_limit_s/getarraysize(getd(".mob_"+.map_post_s$)) );

// ======= Final Kill Settings =======
// * Will the player who gets the final kill be rewarded?
// Only working during a Single Invasion
// - 1: Yes
// - 0: No
set .inva_final,1;

if(.inva_final == 1) {
    // * Reward Type:
    // - 1: Zeny
    // - 2: Cash Points
    // - 512+: Item ID (the Value is already the Item ID)
    set .inva_f_id,40006;
    // * Reward Amount:
    set .inva_f_am,1;
}
// =======*======= END of SETTINGS =======*=======
// Even if .delay is 0, its required to start the timer for force ending the event :I
initnpctimer;
if(.debug) {
    debugmes .n$+": .inva_delay: "+.inva_delay;
    debugmes .n$+": gettimetick(2): "+gettimetick(2);
}
if(.delay == 1 && DELAY(.delay_type,.delay_pos,1) < 1) // If the delay value is empty, set it!!
    DELAY(.delay_type,.delay_pos,2);
    
if(.debug) 
    debugmes .n$+": .inva_delay: "+.inva_delay;

if(.inva_statusinit == 1) // Starting Invasion on Server Start
    donpcevent strnpcinfo(0)+"::OnInvaInit";
// Custom Commands for GM's
bindatcmd "invastart",strnpcinfo(0)+"::OnInvaInit",1,99;
bindatcmd "invaend",strnpcinfo(0)+"::OnInvaForceEnd",1,99;
end;

function    DELAY    {
// Format: DELAY(.delay_type,.delay_pos,1/2);
// getarg(0) = Delay Type
// * 1: Random
// * 2: Fixed Delay
// * 3: Ranged Delay
// getarg(1) = Array Position if getarg(0) == 2 || 3
// getarg(2): Read/Write
// * 1: Read
// * 2: Write
if(getarg(2) == 1) 
    return (.inva_delay - gettimetick(2));
    
switch(getarg(0)) {
    case 1:    set .@new_inva,.time[rand(getarraysize(.time))]; break;
    case 2: set .@new_inva,.time[getarg(1)]; break; 
    case 3: set .@new_inva,.time[rand(getarg(1),getarraysize(.time) - 1)]; break;
}
set .inva_delay,gettimetick(2) + .@new_inva;
return .@new_inva;    
}

}
prontera,150,175,4    script    Invasion Rewarder    110,{

mes .n$;
mes "Hello, "+strcharinfo(0)+"!";
mes "So you want to be rewarded from the Mob Invasion Event, huh?";
mes "Let me take a look at your battle record.";
next;
mes .n$;
if(!InvaKill) {
    mes "It seems like you didn't participated at all or you got your reward already.";
    mes "So I can't give you any kind of reward.";
    mes "Try your best next time.";
    close;
}
mes "You haved killed "+InvaKill+" monsters, good job there.";
next;
mes .n$;
set .@rew_am,InvaKill*.rew_am;
set .@rew_bonus, ( (.rew_bonus > 0)?(InvaKill*.rew_bonus):.rew_bonus);
set .@total,.@rew_am + .@rew_bonus;

if(.rew_type == 1) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + getitemname(.rew_id)+".";
    getitem .rew_id,.@total;
} else if(.rew_type == 2) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + "Cash Points.";
    set #CASHPOINTS,#CASHPOINTS + (.rew_am+.rew_bonus);
}
set InvaKill,0;
close;

OnInit:
set .n$,"["+strnpcinfo(0)+"]";
// =======*======= REWARD SETTINGS =======*=======
// * Reward Type:
// - 0: None
// - 1: Item
// - 2: Cash Points
set .rew_type,1;

// * Reward Bonus
// - 0: Off
// - 1 and higher: On
// = This bonus will be given to the kill additionally.
set .rew_bonus,0;
// ----- Item -----
if(.rew_type == 1) 
    set .rew_id,7929; // Item ID    
// ----- Reward Quantity -----
set .rew_am,10; // Amount per Kill
// ----- NPC Auto Disable -----
// After how many minutes will the NPC be disabled again:
set .rew_dis,3;
disablenpc strnpcinfo(0);
end;
}

 

Edited by Mael
Use a codebox
Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

On 2/2/2021 at 8:09 AM, iSnowFlakes said:

Hi Chris i have issue using your mob invasion

Setting is on Single map,item reward per kill using the npc,


my issues when i used it is.

1. mobs doesn't spawn in one go, seems like it is by batches .

2. it only announces mob remaining when it is only 5 (want it to announce it through all out of the event)

3. doesnt forcibly ends after 36004. need the event to be all normal attacks, skill will be disabled on the spam of the event.

i hope you can help me
 


//===== rAthena Script =======================================
//= Monster Invasion
//===== By ===================================================
//= llchrisll
//===== Version ==============================================
//= 1.0 - Initial Release
//  1.1 - Added custom Commands for GM's to start/end the invasion manually.
//      - Exchanged the Custom Variable Settings for the Reward NPC with
//        the forgotten Cash Points reward (ups..)
//      - Removed the idea about using an Invasion Shop
//      - Fixed reward announcer to display correct lines
//===== Tested With ==========================================
//= rAthena 04/26/2019 Revision
//= GIT Hash: 67e1583f9fec7ac95a954634f6b7600ebe428df0
//===== Description ==========================================
//= There are 2 Invasion Types:
//  - Single
//  - Multiply
//= Each can be seperatly customized, but can not be switched via ingame.
//= Changing settings means to restart/reload the server for them to become active
//= Also there is an "Invasion Rewarder" available after the Invasion,
//  which can be turned on or off
//  To change the reward itself, scroll down to the bottom of the file
//  where the NPC is located. There are extra settings.
//= See "OnInit:" for the main settings
//===== Comments =============================================
//= None yet... 
//===========================================================
-    script    MobInvaInit    -1,{
function    DELAY;

OnTimer1000: // Every Second
stopnpctimer;
set .s,.s + 1;
if(.debug) 
    // Showing Debug every minute only.
    if(.s%60 == 0) debugmes .n$+": Delay Timer: "+.s+" seconds (Minutes: "+(.s/60)+"), Delay Function returns: "+DELAY(.delay_type,.delay_pos,1)+", Invasion Re-/Starts: "+.time[.delay_pos]+" (in seconds), Force End: "+.inva_fend+" (in seconds)";
if(.delay == 1 && .s == DELAY(.delay_type,.delay_pos,1) ) 
    donpcevent strnpcinfo(0)+"::OnInvaInit";
else if( .s == .inva_fend && .inva_status) 
    donpcevent strnpcinfo(0)+"::OnInvaForceEnd";
initnpctimer;
end;


OnClock1300: // 1 p.m.
OnClock2000:
if(.delay == 1) // Delay Usage active
    end;
    
OnInvaInit:
if(.inva_status) end;

if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    disablenpc "Invasion Rewarder";

switch(.inva_type) {
    
    // Single Town Invasion
    case 1:
    if(!.s_inva_spec) { // No Map Specification > Random
    
        if(rand(1,10) <= 5) { // 50% chance to use either a big city or a small one
            set .t,rand(getarraysize(.map_b$));
            set .map_use,1; // Use big Maps
        } else {
            set .t,rand(getarraysize(.map_s$));
            set .map_use,2; // Use small Maps
        }
    } else {
        set .map_use,.s_inva_spec;
        set .t,.s_inva_pos;
    }
    if(.map_use == 1) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.t])); set .@m,.@m + 1) {
            monster .map_b$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_b$);
        }
        announce .n$+": The town "+.map_b$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    
    } else if(.map_use == 2) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.t])); set .@m,.@m + 1) {
            monster .map_s$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_s$);
        }
        announce .n$+": The town "+.map_s$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    }
    break;
    
    // Multiply Town Invasion
    case 2:
    if( .inva_spawn == 1) {
        for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
            }
            announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
        
        sleep 500;
        
        for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
            }
            announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
    // * Spawn Option - Specific Maps
    } else if( .inva_spawn == 2) {
        
        set .@map_am,.inva_maps; // Copying Map Quantity
        
        if(.debug)
            debugmes .n$+": Map Quantity - .inva_maps: "+.inva_maps+" > .@map_am";
        // * Map Size - Big Maps 
        if( .inva_size == 1) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_b$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_b$);
                
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
                
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: Yes";
                    
                while ( .@c < .@map_am ) {
                    if(.debug) 
                        debugmes .n$+": Big Maps - Counter: "+.@c+", Map Index: "+.@t;
                
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if((.@t+1) == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],(.@t+1); // Copying already use maps.
                    set .@c,.@c + 1;
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .@map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
            
        // * Map Size - Small Maps 
        } else if( .inva_size == 2) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_s$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_s$);
            
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
            
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
                while ( .@c < .@map_am ) {
                    
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if(.@t == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],.@t; // Copying already use maps.
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
                
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
        }
    }
    break;
    
}
set .inva_status,1;
end;


OnMobSingleKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set .MobSKilled,.MobSKilled - 1;
switch(.MobSKilled) {
    case 0:
    announce .n$+": Congratulation to ["+strcharinfo(0)+"] who delivered the final blow!!! Nicely Done!!!",0;
    if(.inva_final) {
        announce .n$+": You also get an \"Final Kill Reward\", just take a look in the Chat Box. See ya next time *g*",bc_self;
        dispbottom .n$+": You have been rewarded with:";
        if(.inva_f_id == 1) {
            set Zeny,Zeny + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Zeny.";
        } else if(.inva_f_id == 2) {
            set #CASHPOINTS,#CASHPOINTS + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Cash Points. New Balance is "+#CASHPOINTS+".";
        } else if(.inva_f_id >= 512) {
            getitem .inva_f_id,.inva_f_am;
            dispbottom .n$+": "+.inva_f_am+"x "+getitemname(.inva_f_id)+".";
        }
    }
    sleep 10000;
    donpcevent strnpcinfo(0)+"::OnInvaEnd";
    break;
    
    case 1:
    mapannounce strcharinfo(3),.n$+": JUST "+.MobSKilled+" MONSTER is left!!!! FINAL BLOW, GO GO!!!",bc_yellow;
    break;
    
    case 2:
    case 3:
    case 4:
    mapannounce strcharinfo(3),.n$+": Only "+.MobSKilled+" monsters are left!!!! We can do it!!!",bc_yellow;
    break;

    case 5:
    mapannounce strcharinfo(3),.n$+": LAST "+.MobSKilled+"!!!! We can do it!!!",bc_yellow;
    break;
    
    default: break;
}
end;

OnMobMultiKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0)
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set @loc,0;
for ( set .@l,0; .@l < getarraysize(.map_b$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_b$[.@l]) {
        set @loc,1;
        set @map,.@l;
        break;
    }
    
for ( set .@l,0; .@l < getarraysize(.map_s$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_s$[.@l]) {
        set @loc,2;
        set @map,.@l;
        break;
    }

OnMMobKilled:
if(.debug) 
    debugmes .n$+": 2nd Loc Check: @Loc; "+@loc+", @map: "+@map;
switch( @loc ) {
    
    case 1: 
    setd(".Mob_"+.map_post_b$[@map]+"_Killed"),getd(".Mob_"+.map_post_b$[@map]+"_Killed") - 1; 
    if(.debug)
        debugmes .n$+": Mobs: "+mobcount(.map_b$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_b$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_b$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_b$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
    
    case 2: 
    setd(".Mob_"+.map_post_s$[@map]+"_Killed"),getd(".Mob_"+.map_post_s$[@map]+"_Killed") - 1; 
    if(.debug) 
        debugmes .n$+": Mobs: "+mobcount(.map_s$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_s$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_s$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_s$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
}
end;

OnOtherTown:
for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
        set .@mapb_left$,.@mapb_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");

for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
        set .@maps_left$,.@maps_left$ + .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");

if(.@maps_left$ == "" && .@mapb_left$ == "")
    donpcevent strnpcinfo(0)+"::OnInvaEnd";

announce .n$+": In the "+ ( (.@mapb_left$ != "")?"big towns "+.@mapb_left$+ ( (.@maps_left$ != "")?" and small towns "+.@maps_left$:""):"small towns "+.@maps_left$)+" are still Monsters, please help use to defeat them!!!",0;
end;

OnInvaEnd:
announce .n$+": Thank you guys for your help in defeating the invaders, we will counting on you for the next time as well.",0;
donpcevent strnpcinfo(0)+"::OnInvaRestart";
end;

OnInvaForceEnd:
announce .n$+": NOOOOO!!! The monsters successfully invaded the towns, RETREAT GUARDS!!!",0;
sleep 10000;
announce .n$+": Brave Fighters, I thank you for your support, but we failed!!",0;
sleep 10000;
announce .n$+": Let's regroup and let's try again, I will inform you when we are ready!!",0;

OnInvaRestart:
DELAY(.delay_type,.delay_pos,2);
// Removing Mobs which kinda survived
if(.inva_type == 1) // Single Town
    if(.map_use == 1) killmonster .map_b$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    else killmonster .map_s$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    
else if(.inva_type == 2) { // Multi Town
    for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
        killmonster .map_b$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
        
    for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1)
        killmonster .map_s$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
    }
set .inva_status,0;
if(.delay == 1) set .s,0; // Reseting Delay Counter
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) {
    enablenpc "Invasion Rewarder";
    announce .n$+": Visit the \"Invasion Rewarder\" to recieve rewards for your kills. But hurry, he will disappear in "+getvariableofnpc(.rew_dis,"Invasion Rewarder")+" minutes.",0;
    donpcevent strnpcinfo(0)+"::OnRewardDisable";
}
end;

// Auto Disable Reward NPC
OnRewardDisable:
set .m,getvariableofnpc(.rew_dis,"Invasion Rewarder");
while( .m != 0 ) {
    switch(.m) {
        case 4: 
        case 3:
        case 2:
        announce .n$+": The \"Invasion Rewarder\" will disappear in "+.m+" minutes.",bc_all; break;
        case 1: announce .n$+": HURRY, the \"Invasion Rewarder\" will disappear in 1 minute.",bc_all; break;
    }
    set .m,.m - 1;
    sleep 60000;
}        
announce "Invasion Rewarder: Okay, I'm done here. See ya next time!!!",0;
set .m,0;
disablenpc "Invasion Rewarder";
end;

OnPCLoginEvent:
if(.inva_status == 0) end;
announce .n$+": The Monster Invasion Event is currently running, please hurry and help us!!",bc_self;
sleep2 2000;
if(.inva_type == 1) 
    set .@map_left$,( (.map_use == 1) ? .map_b$[.t]:.map_s$[.t]);
else if(.inva_type == 2) {
    for ( set .@m,0; .@m < getarraysize(.map_b$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");
            
    for ( set .@m,0; .@m < getarraysize(.map_s$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ +" and "+ .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");
}
announce .n$+": We are defending at "+ .@map_left$+"!!!",bc_self;
end;

OnInit:
set .n$,"[Ragnarok Guard]";
// Debug Mode - See Map Server Console for Debug messages
set .debug,0;
// ======= Invasion Type =======
// - 1: Single
// - 2: Multiply
set .inva_type,1;
// ====== Single Invasion Settings =========
if(.inva_type == 1) {
    // * Specific Map Usage
    // - 0 = Random
    // - 1 = Big Maps
    // - 2 = Small Maps
    set .s_inva_spec,0;

    if(.s_inva_spec > 0) {
        // * Map Index
        // X = Array Index of the Map Array
        set .s_inva_pos,0;
    }
// ======= Multiply Invasion Settings ========
} else if(.inva_type == 2) {
    // * Spawn Option
    // - 1: All Maps
    // - 2: Specific Maps
    set .inva_spawn,2;

    if(.inva_spawn == 2) {
        // * Map Usage:
        // - 1: Big Maps
        // - 2: Small Maps
        set .inva_size,1;
        
        // * Map Amount:
        // - 0: All Maps from .inva_size above
        // - 1+: ...
        // Note: If this value exceeds the size of the map array, 
        // then it will use all maps of .inva_size.
        set .inva_maps,0;
 
        if(.inva_maps > 0 && .inva_maps < ( (.inva_size == 1)?getarraysize(.map_b$):getarraysize(.map_s$) ) ) 
        // * Map Randoming:
        // - 0: No
        // - 1: Yes
        // Note: Map Randoming is only possible when not all maps are wanted
        // It would be ineffective to make map randoming when there are all maps active :I
        set .inva_rand,1;
    }
}
// * Invasion on Server Start
// - 0: No
// - 1: Yes
set .inva_statusinit,0;
// * Invasion Force End
// - 0: Not used
// - 1+: ...
// Note: The Event will automatically end after this value has passed (in seconds)
set .inva_fend,3600; // 1 Hour
// =======*======= DELAY SETTINGS =======*=======
// * Delay Usage
// - 0: Off - OnClockXXXX will be used
// - 1: On
set .delay,0;
// * Delay Type
// - 1: Random (Default)
// - 2: Fixed Delay
// - 3: Ranged Delay
set .delay_type,1;

// ---- Fixed Delay ----
// Array Position in ".time"
if(.delay_type == 2) 
    set .delay_pos,0;
// ---- Ranged Delay ----
// Array Position for start index
if(.delay_type == 3) 
    set .delay_pos,3;

// * Delay Times
setarray .time[0],
// In Seconds  -  is equal to  -  Array Position
        10800, // 3 Hours      -  0
        14400, // 4 Hours      -  1
        21600, // 6 Hours      -  2
        86400, // 1 Day        -  3
        172800, // 2 Days      -  4    
        259200; // 3 Days      -  5

// =======*======= MONSTER SETTINGS =======*=======
// * Mob Quantity Limit depending on the map size
// - Big Maps
set .m_limit_b,100;
// - Small Maps
set .m_limit_s,30;

// * Maps List
// - Big Maps 
setarray .map_b$[0],"prontera","geffen","payon","morocc","aldebaran","alberta";
// For every map you have to add an postfix in the same order,
// which has been put in the array for the Maps
// After this, just set an array with the Mob IDs where the
// array name contains the postfix you set-up, see the examples
setarray .map_post_b$[0],"pron","gef","pay","mor","alde","alb";
// - Small Maps
setarray .map_s$[0],"izlude";
setarray .map_post_s$[0],"izl";
// ======= Monster ID's =======
// ------ Big Maps ------
// * Prontera - Mantis, Thief Bug Male, Argos, Side Winder
setarray .mob_pron[0],1139,1054,1100,1037;
// * Geffen - Poison Spore, Ghoul, Jakk, High Orc
setarray .mob_gef[0],1855,1036,1130,1213;
// * Payon - Zombie, Elder Willow, Munak, Nine Tail, Drainliar
setarray .mob_pay[0],1015,1033,1026,1180,1111;
// * Morocc - Requiem, Isis, Mummy, Minorous
setarray .mob_mor[0],1164,1029,1041,1149;
// * Aldebaran - Cramp, Penomena, Punk, Orc Archer, Bathory
setarray .mob_alde[0],1209,1029,1199,1189,1102;
// * Alberta - Pirate Skeleton, Penomena, Poison Spore, Whisper, Mimic
setarray .mob_alb[0],1071,1029,1077,1179,1191;
// ------ Small Maps ------
// * Izlude - Obeaune, Merman, Swordfish, Strouf
setarray .mob_izl[0],1044,1264,1069,1065;

// ------ Mob Amount Calculation for Big Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_b$); set .@c,.@c + 1) 
    setd(".mam_"+.map_post_b$[.@c]),( .m_limit_b/getarraysize(getd(".mob_"+.map_post_b$)) );
    
// ------ Mob Amount Calculation for Small Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_s$); set .@c,.@c + 1)
    setd(".mam_"+.map_post_s$[.@c]),( .m_limit_s/getarraysize(getd(".mob_"+.map_post_s$)) );

// ======= Final Kill Settings =======
// * Will the player who gets the final kill be rewarded?
// Only working during a Single Invasion
// - 1: Yes
// - 0: No
set .inva_final,1;

if(.inva_final == 1) {
    // * Reward Type:
    // - 1: Zeny
    // - 2: Cash Points
    // - 512+: Item ID (the Value is already the Item ID)
    set .inva_f_id,40006;
    // * Reward Amount:
    set .inva_f_am,1;
}
// =======*======= END of SETTINGS =======*=======
// Even if .delay is 0, its required to start the timer for force ending the event :I
initnpctimer;
if(.debug) {
    debugmes .n$+": .inva_delay: "+.inva_delay;
    debugmes .n$+": gettimetick(2): "+gettimetick(2);
}
if(.delay == 1 && DELAY(.delay_type,.delay_pos,1) < 1) // If the delay value is empty, set it!!
    DELAY(.delay_type,.delay_pos,2);
    
if(.debug) 
    debugmes .n$+": .inva_delay: "+.inva_delay;

if(.inva_statusinit == 1) // Starting Invasion on Server Start
    donpcevent strnpcinfo(0)+"::OnInvaInit";
// Custom Commands for GM's
bindatcmd "invastart",strnpcinfo(0)+"::OnInvaInit",1,99;
bindatcmd "invaend",strnpcinfo(0)+"::OnInvaForceEnd",1,99;
end;

function    DELAY    {
// Format: DELAY(.delay_type,.delay_pos,1/2);
// getarg(0) = Delay Type
// * 1: Random
// * 2: Fixed Delay
// * 3: Ranged Delay
// getarg(1) = Array Position if getarg(0) == 2 || 3
// getarg(2): Read/Write
// * 1: Read
// * 2: Write
if(getarg(2) == 1) 
    return (.inva_delay - gettimetick(2));
    
switch(getarg(0)) {
    case 1:    set .@new_inva,.time[rand(getarraysize(.time))]; break;
    case 2: set .@new_inva,.time[getarg(1)]; break; 
    case 3: set .@new_inva,.time[rand(getarg(1),getarraysize(.time) - 1)]; break;
}
set .inva_delay,gettimetick(2) + .@new_inva;
return .@new_inva;    
}

}
prontera,150,175,4    script    Invasion Rewarder    110,{

mes .n$;
mes "Hello, "+strcharinfo(0)+"!";
mes "So you want to be rewarded from the Mob Invasion Event, huh?";
mes "Let me take a look at your battle record.";
next;
mes .n$;
if(!InvaKill) {
    mes "It seems like you didn't participated at all or you got your reward already.";
    mes "So I can't give you any kind of reward.";
    mes "Try your best next time.";
    close;
}
mes "You haved killed "+InvaKill+" monsters, good job there.";
next;
mes .n$;
set .@rew_am,InvaKill*.rew_am;
set .@rew_bonus, ( (.rew_bonus > 0)?(InvaKill*.rew_bonus):.rew_bonus);
set .@total,.@rew_am + .@rew_bonus;

if(.rew_type == 1) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + getitemname(.rew_id)+".";
    getitem .rew_id,.@total;
} else if(.rew_type == 2) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + "Cash Points.";
    set #CASHPOINTS,#CASHPOINTS + (.rew_am+.rew_bonus);
}
set InvaKill,0;
close;

OnInit:
set .n$,"["+strnpcinfo(0)+"]";
// =======*======= REWARD SETTINGS =======*=======
// * Reward Type:
// - 0: None
// - 1: Item
// - 2: Cash Points
set .rew_type,1;

// * Reward Bonus
// - 0: Off
// - 1 and higher: On
// = This bonus will be given to the kill additionally.
set .rew_bonus,0;
// ----- Item -----
if(.rew_type == 1) 
    set .rew_id,7929; // Item ID    
// ----- Reward Quantity -----
set .rew_am,10; // Amount per Kill
// ----- NPC Auto Disable -----
// After how many minutes will the NPC be disabled again:
set .rew_dis,3;
disablenpc strnpcinfo(0);
end;
}

 

Please use codebox next time, so it doesn't create any unnecessary lines.
Also I don't provide any script modifications anymore, as I stopped scripting since the Translation project take-over.
So as long they are no bugs, I won't do something to the scripts. Sorry.

Edited by llchrisll
Codeboxed the quote....
  • Like 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   0
  • Joined:  03/11/17
  • Last Seen:  

Hi Chris

It's really great to see, that you're still supporting your script.

May I know, the issue with Mass Seller.

 

If I choose "Sell item", then "continue" - nothing happens.

Even don't see CLOSE button in the dialogue.

Map servers says:

[Error]: run_script: infinity loop !
[Debug]: Source (NPC): Mass Seller at prontera (163,174)

 

Dont you know, what can it be? 

 

Thx. 

 

57154-clip-4kb.png

d0f3d-clip-28kb.jpg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.01
  • Content Count:  35
  • Reputation:   1
  • Joined:  10/22/20
  • Last Seen:  

On 2/11/2021 at 1:31 AM, llchrisll said:

Please use codebox next time, so it doesn't create any unnecessary lines.
Also I don't provide any script modifications anymore, as I stopped scripting since the Translation project take-over.
So as long they are no bugs, I won't do something to the scripts. Sorry.

im so sorry for that kinda newbie here,

its kinda buggy ,

1. not announcing everytime it kills (only announces once reached 5 remaining)
2. mobs did not spawn all in one time, (there is a certain number will spawn as 1st batch then next batch will spawn)
3. its not force ending after the given force end time

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

On 2/15/2021 at 2:41 AM, iSnowFlakes said:

im so sorry for that kinda newbie here,

its kinda buggy ,

1. not announcing everytime it kills (only announces once reached 5 remaining)
2. mobs did not spawn all in one time, (there is a certain number will spawn as 1st batch then next batch will spawn)
3. its not force ending after the given force end time

Well 1+2 are intentional, mostly.
Well gonna take a look at it again, when I have more time or rather motivation, still needs to fix other scripts, Battle Royale and Dynamic BG Arena >_>.
But the translation project takes time so I pretty much focus solely on that.
Sorry, that I can't fix my scripts ASAP.

 

On 2/13/2021 at 11:01 PM, Timokha said:

Hi Chris

It's really great to see, that you're still supporting your script.

May I know, the issue with Mass Seller.

 

If I choose "Sell item", then "continue" - nothing happens.

Even don't see CLOSE button in the dialogue.

Map servers says:

[Error]: run_script: infinity loop !
[Debug]: Source (NPC): Mass Seller at prontera (163,174)

 

Dont you know, what can it be? 

 

Thx. 

 

57154-clip-4kb.png

d0f3d-clip-28kb.jpg

infinite loop is that it needs a pause in between, gonna add it to my todo list regarding scripts to look at it further.

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

On 2/2/2021 at 8:09 AM, iSnowFlakes said:

Hi Chris i have issue using your mob invasion

Setting is on Single map,item reward per kill using the npc,


my issues when i used it is.

1. mobs doesn't spawn in one go, seems like it is by batches .

2. it only announces mob remaining when it is only 5 (want it to announce it through all out of the event)

3. doesnt forcibly ends after 3600

4. need the event to be all normal attacks, skill will be disabled on the spam of the event.

i hope you can help me
 


//===== rAthena Script =======================================
//= Monster Invasion
//===== By ===================================================
//= llchrisll
//===== Version ==============================================
//= 1.0 - Initial Release
//  1.1 - Added custom Commands for GM's to start/end the invasion manually.
//      - Exchanged the Custom Variable Settings for the Reward NPC with
//        the forgotten Cash Points reward (ups..)
//      - Removed the idea about using an Invasion Shop
//      - Fixed reward announcer to display correct lines
//===== Tested With ==========================================
//= rAthena 04/26/2019 Revision
//= GIT Hash: 67e1583f9fec7ac95a954634f6b7600ebe428df0
//===== Description ==========================================
//= There are 2 Invasion Types:
//  - Single
//  - Multiply
//= Each can be seperatly customized, but can not be switched via ingame.
//= Changing settings means to restart/reload the server for them to become active
//= Also there is an "Invasion Rewarder" available after the Invasion,
//  which can be turned on or off
//  To change the reward itself, scroll down to the bottom of the file
//  where the NPC is located. There are extra settings.
//= See "OnInit:" for the main settings
//===== Comments =============================================
//= None yet... 
//===========================================================
-    script    MobInvaInit    -1,{
function    DELAY;

OnTimer1000: // Every Second
stopnpctimer;
set .s,.s + 1;
if(.debug) 
    // Showing Debug every minute only.
    if(.s%60 == 0) debugmes .n$+": Delay Timer: "+.s+" seconds (Minutes: "+(.s/60)+"), Delay Function returns: "+DELAY(.delay_type,.delay_pos,1)+", Invasion Re-/Starts: "+.time[.delay_pos]+" (in seconds), Force End: "+.inva_fend+" (in seconds)";
if(.delay == 1 && .s == DELAY(.delay_type,.delay_pos,1) ) 
    donpcevent strnpcinfo(0)+"::OnInvaInit";
else if( .s == .inva_fend && .inva_status) 
    donpcevent strnpcinfo(0)+"::OnInvaForceEnd";
initnpctimer;
end;


OnClock1300: // 1 p.m.
OnClock2000:
if(.delay == 1) // Delay Usage active
    end;
    
OnInvaInit:
if(.inva_status) end;

if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    disablenpc "Invasion Rewarder";

switch(.inva_type) {
    
    // Single Town Invasion
    case 1:
    if(!.s_inva_spec) { // No Map Specification > Random
    
        if(rand(1,10) <= 5) { // 50% chance to use either a big city or a small one
            set .t,rand(getarraysize(.map_b$));
            set .map_use,1; // Use big Maps
        } else {
            set .t,rand(getarraysize(.map_s$));
            set .map_use,2; // Use small Maps
        }
    } else {
        set .map_use,.s_inva_spec;
        set .t,.s_inva_pos;
    }
    if(.map_use == 1) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.t])); set .@m,.@m + 1) {
            monster .map_b$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_b$);
        }
        announce .n$+": The town "+.map_b$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    
    } else if(.map_use == 2) {
        for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.t])); set .@m,.@m + 1) {
            monster .map_s$[.t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobSingleKilled";
            set .MobSKilled,.MobSKilled + getd(".mam_"+.map_post_s$);
        }
        announce .n$+": The town "+.map_s$[.t]+" is being invaded by "+.MobSKilled+" monsters, please help use to defend it.",0;
    }
    break;
    
    // Multiply Town Invasion
    case 2:
    if( .inva_spawn == 1) {
        for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
            }
            announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
        
        sleep 500;
        
        for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) {
            for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
            }
            announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
        }
    // * Spawn Option - Specific Maps
    } else if( .inva_spawn == 2) {
        
        set .@map_am,.inva_maps; // Copying Map Quantity
        
        if(.debug)
            debugmes .n$+": Map Quantity - .inva_maps: "+.inva_maps+" > .@map_am";
        // * Map Size - Big Maps 
        if( .inva_size == 1) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_b$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_b$);
                
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
                
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: Yes";
                    
                while ( .@c < .@map_am ) {
                    if(.debug) 
                        debugmes .n$+": Big Maps - Counter: "+.@c+", Map Index: "+.@t;
                
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if((.@t+1) == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],(.@t+1); // Copying already use maps.
                    set .@c,.@c + 1;
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
            
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .@map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Big Maps - Map Index: "+.@t+", Map Name: "+.map_b$[.@t];
                        debugmes .n$+": Big Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_b$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_b$[.@t])); set .@m,.@m + 1) {
                        monster .map_b$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_b$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_b$[.@t]+"_Killed"),getd(".Mob_"+.map_post_b$[.@t]+"_Killed") + getd(".mam_"+.map_post_b$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Big Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_b$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_b$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_b$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_b$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_b$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
            
        // * Map Size - Small Maps 
        } else if( .inva_size == 2) {
        
            // - Checking if .map_am exceeds the size of the map array, or is 0
            if( .@map_am > getarraysize(.map_s$) || .@map_am == 0)
                set .@map_am,getarraysize(.map_s$);
            
            if(.debug) 
                debugmes .n$+": Map Quantity - Check: .@map_am: "+.@map_am;
            
            // * Map Randomness - Yes
            if( .inva_rand == 1) {
                while ( .@c < .@map_am ) {
                    
                    set .@t,rand(.@map_am);
                    set .@f,0;
                        
                    for ( set .@e,0; .@e < getarraysize(.@t_c); set .@e,.@e + 1) 
                        if(.@t == .@t_c[.@e]) {
                            set .@f,1;
                            break;
                        }
                        
                    if(.@f == 1) continue;
                    
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                    setarray .@t_c[getarraysize(.@t_c)],.@t; // Copying already use maps.
                }
                    
            // * Map Randomness - No
            } else if( .inva_rand == 0) {
                
                if(.debug) 
                    debugmes .n$+": Map Randomness: No";
                
                for ( set .@t,0; .@t < .map_am; set .@t,.@t + 1) {
                    if(.debug) {
                        debugmes .n$+": Small Maps - Map Index: "+.@t+", Map Name: "+.map_s$[.@t];
                        debugmes .n$+": Small Maps - Mob Array Size: "+getarraysize(getd(".mob_"+.map_post_s$[.@t]));
                    }
                    for ( set .@m,0; .@m < getarraysize(getd(".mob_"+.map_post_s$[.@t])); set .@m,.@m + 1) {
                        monster .map_s$[.@t],0,0,""+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0),getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),getd(".mam_"+.map_post_s$[.@t]),strnpcinfo(0)+"::OnMobMultiKilled";
                        setd(".Mob_"+.map_post_s$[.@t]+"_Killed"),getd(".Mob_"+.map_post_s$[.@t]+"_Killed") + getd(".mam_"+.map_post_s$[.@t]);
                        if(.debug) {
                            debugmes .n$+": Small Maps - Map Index: "+.@t+", Mob Index: "+.@m+", Map Name: "+.map_s$[.@t]+", Mob ID + Name: "+getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]")+"; "+getmonsterinfo(getd(".mob_"+.map_post_s$[.@t]+"["+.@m+"]"),0);
                            debugmes .n$+": Total Mob Amount - Map Index: "+.@t+": "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+", Spawn Amount per Mob: "+getd(".mam_"+.map_post_s$[.@t]);
                        }
                    }
                    announce .n$+": The town "+.map_s$[.@t]+" is being invaded by "+getd(".Mob_"+.map_post_s$[.@t]+"_Killed")+" monsters, please help use to defend it.",0;
                }
            }
        }
    }
    break;
    
}
set .inva_status,1;
end;


OnMobSingleKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) 
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set .MobSKilled,.MobSKilled - 1;
switch(.MobSKilled) {
    case 0:
    announce .n$+": Congratulation to ["+strcharinfo(0)+"] who delivered the final blow!!! Nicely Done!!!",0;
    if(.inva_final) {
        announce .n$+": You also get an \"Final Kill Reward\", just take a look in the Chat Box. See ya next time *g*",bc_self;
        dispbottom .n$+": You have been rewarded with:";
        if(.inva_f_id == 1) {
            set Zeny,Zeny + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Zeny.";
        } else if(.inva_f_id == 2) {
            set #CASHPOINTS,#CASHPOINTS + .inva_f_am;
            dispbottom .n$+": "+.inva_f_am+" Cash Points. New Balance is "+#CASHPOINTS+".";
        } else if(.inva_f_id >= 512) {
            getitem .inva_f_id,.inva_f_am;
            dispbottom .n$+": "+.inva_f_am+"x "+getitemname(.inva_f_id)+".";
        }
    }
    sleep 10000;
    donpcevent strnpcinfo(0)+"::OnInvaEnd";
    break;
    
    case 1:
    mapannounce strcharinfo(3),.n$+": JUST "+.MobSKilled+" MONSTER is left!!!! FINAL BLOW, GO GO!!!",bc_yellow;
    break;
    
    case 2:
    case 3:
    case 4:
    mapannounce strcharinfo(3),.n$+": Only "+.MobSKilled+" monsters are left!!!! We can do it!!!",bc_yellow;
    break;

    case 5:
    mapannounce strcharinfo(3),.n$+": LAST "+.MobSKilled+"!!!! We can do it!!!",bc_yellow;
    break;
    
    default: break;
}
end;

OnMobMultiKilled:
if(!.inva_status) end; // Shouldn't be possible
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0)
    set InvaKill,InvaKill + 1; // Kill Counter for Reward
set @loc,0;
for ( set .@l,0; .@l < getarraysize(.map_b$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_b$[.@l]) {
        set @loc,1;
        set @map,.@l;
        break;
    }
    
for ( set .@l,0; .@l < getarraysize(.map_s$); set .@l,.@l + 1) 
    if(strcharinfo(3) == .map_s$[.@l]) {
        set @loc,2;
        set @map,.@l;
        break;
    }

OnMMobKilled:
if(.debug) 
    debugmes .n$+": 2nd Loc Check: @Loc; "+@loc+", @map: "+@map;
switch( @loc ) {
    
    case 1: 
    setd(".Mob_"+.map_post_b$[@map]+"_Killed"),getd(".Mob_"+.map_post_b$[@map]+"_Killed") - 1; 
    if(.debug)
        debugmes .n$+": Mobs: "+mobcount(.map_b$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_b$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_b$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_b$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
    
    case 2: 
    setd(".Mob_"+.map_post_s$[@map]+"_Killed"),getd(".Mob_"+.map_post_s$[@map]+"_Killed") - 1; 
    if(.debug) 
        debugmes .n$+": Mobs: "+mobcount(.map_s$[@map],strnpcinfo(0)+"::OnMobMultiKilled")+", Variable: "+getd(".Mob_"+.map_post_s$[@map]+"_Killed");
    if(getd(".Mob_"+.map_post_s$[@map]+"_Killed") > 0) 
        mapannounce strcharinfo(3),.n$+": The player ["+strcharinfo(0)+"] has killed another monster, "+getd(".Mob_"+.map_post_s$[@map]+"_Killed")+" monsters are left!!!! Good work !!!",0;
    else {
        announce .n$+": Every Monster in "+.map_s$[@map]+" has been defeated, thank you guys!!!",0;
        donpcevent strnpcinfo(0)+"::OnOtherTown";
    }
    break;
}
end;

OnOtherTown:
for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
        set .@mapb_left$,.@mapb_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");

for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1) 
    if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
        set .@maps_left$,.@maps_left$ + .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");

if(.@maps_left$ == "" && .@mapb_left$ == "")
    donpcevent strnpcinfo(0)+"::OnInvaEnd";

announce .n$+": In the "+ ( (.@mapb_left$ != "")?"big towns "+.@mapb_left$+ ( (.@maps_left$ != "")?" and small towns "+.@maps_left$:""):"small towns "+.@maps_left$)+" are still Monsters, please help use to defeat them!!!",0;
end;

OnInvaEnd:
announce .n$+": Thank you guys for your help in defeating the invaders, we will counting on you for the next time as well.",0;
donpcevent strnpcinfo(0)+"::OnInvaRestart";
end;

OnInvaForceEnd:
announce .n$+": NOOOOO!!! The monsters successfully invaded the towns, RETREAT GUARDS!!!",0;
sleep 10000;
announce .n$+": Brave Fighters, I thank you for your support, but we failed!!",0;
sleep 10000;
announce .n$+": Let's regroup and let's try again, I will inform you when we are ready!!",0;

OnInvaRestart:
DELAY(.delay_type,.delay_pos,2);
// Removing Mobs which kinda survived
if(.inva_type == 1) // Single Town
    if(.map_use == 1) killmonster .map_b$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    else killmonster .map_s$[.t],strnpcinfo(0)+"::OnMobSingleKilled";
    
else if(.inva_type == 2) { // Multi Town
    for ( set .@t,0; .@t < getarraysize(.map_b$); set .@t,.@t + 1) 
        killmonster .map_b$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
        
    for ( set .@t,0; .@t < getarraysize(.map_s$); set .@t,.@t + 1)
        killmonster .map_s$[.@t],strnpcinfo(0)+"::OnMobMultiKilled";
    }
set .inva_status,0;
if(.delay == 1) set .s,0; // Reseting Delay Counter
if(getvariableofnpc(.rew_type,"Invasion Rewarder") > 0) {
    enablenpc "Invasion Rewarder";
    announce .n$+": Visit the \"Invasion Rewarder\" to recieve rewards for your kills. But hurry, he will disappear in "+getvariableofnpc(.rew_dis,"Invasion Rewarder")+" minutes.",0;
    donpcevent strnpcinfo(0)+"::OnRewardDisable";
}
end;

// Auto Disable Reward NPC
OnRewardDisable:
set .m,getvariableofnpc(.rew_dis,"Invasion Rewarder");
while( .m != 0 ) {
    switch(.m) {
        case 4: 
        case 3:
        case 2:
        announce .n$+": The \"Invasion Rewarder\" will disappear in "+.m+" minutes.",bc_all; break;
        case 1: announce .n$+": HURRY, the \"Invasion Rewarder\" will disappear in 1 minute.",bc_all; break;
    }
    set .m,.m - 1;
    sleep 60000;
}        
announce "Invasion Rewarder: Okay, I'm done here. See ya next time!!!",0;
set .m,0;
disablenpc "Invasion Rewarder";
end;

OnPCLoginEvent:
if(.inva_status == 0) end;
announce .n$+": The Monster Invasion Event is currently running, please hurry and help us!!",bc_self;
sleep2 2000;
if(.inva_type == 1) 
    set .@map_left$,( (.map_use == 1) ? .map_b$[.t]:.map_s$[.t]);
else if(.inva_type == 2) {
    for ( set .@m,0; .@m < getarraysize(.map_b$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_b$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ + .map_b$[.@m]+ ( (.map_b$[.@m+1] != "")?", ":"");
            
    for ( set .@m,0; .@m < getarraysize(.map_s$); set .@m,.@m + 1) 
        if(getd(".Mob_"+.map_post_s$[.@m]+"_Killed") > 0) 
            set .@map_left$,.@map_left$ +" and "+ .map_s$[.@m]+ ( (.map_s$[.@m+1] != "")?", ":"");
}
announce .n$+": We are defending at "+ .@map_left$+"!!!",bc_self;
end;

OnInit:
set .n$,"[Ragnarok Guard]";
// Debug Mode - See Map Server Console for Debug messages
set .debug,0;
// ======= Invasion Type =======
// - 1: Single
// - 2: Multiply
set .inva_type,1;
// ====== Single Invasion Settings =========
if(.inva_type == 1) {
    // * Specific Map Usage
    // - 0 = Random
    // - 1 = Big Maps
    // - 2 = Small Maps
    set .s_inva_spec,0;

    if(.s_inva_spec > 0) {
        // * Map Index
        // X = Array Index of the Map Array
        set .s_inva_pos,0;
    }
// ======= Multiply Invasion Settings ========
} else if(.inva_type == 2) {
    // * Spawn Option
    // - 1: All Maps
    // - 2: Specific Maps
    set .inva_spawn,2;

    if(.inva_spawn == 2) {
        // * Map Usage:
        // - 1: Big Maps
        // - 2: Small Maps
        set .inva_size,1;
        
        // * Map Amount:
        // - 0: All Maps from .inva_size above
        // - 1+: ...
        // Note: If this value exceeds the size of the map array, 
        // then it will use all maps of .inva_size.
        set .inva_maps,0;
 
        if(.inva_maps > 0 && .inva_maps < ( (.inva_size == 1)?getarraysize(.map_b$):getarraysize(.map_s$) ) ) 
        // * Map Randoming:
        // - 0: No
        // - 1: Yes
        // Note: Map Randoming is only possible when not all maps are wanted
        // It would be ineffective to make map randoming when there are all maps active :I
        set .inva_rand,1;
    }
}
// * Invasion on Server Start
// - 0: No
// - 1: Yes
set .inva_statusinit,0;
// * Invasion Force End
// - 0: Not used
// - 1+: ...
// Note: The Event will automatically end after this value has passed (in seconds)
set .inva_fend,3600; // 1 Hour
// =======*======= DELAY SETTINGS =======*=======
// * Delay Usage
// - 0: Off - OnClockXXXX will be used
// - 1: On
set .delay,0;
// * Delay Type
// - 1: Random (Default)
// - 2: Fixed Delay
// - 3: Ranged Delay
set .delay_type,1;

// ---- Fixed Delay ----
// Array Position in ".time"
if(.delay_type == 2) 
    set .delay_pos,0;
// ---- Ranged Delay ----
// Array Position for start index
if(.delay_type == 3) 
    set .delay_pos,3;

// * Delay Times
setarray .time[0],
// In Seconds  -  is equal to  -  Array Position
        10800, // 3 Hours      -  0
        14400, // 4 Hours      -  1
        21600, // 6 Hours      -  2
        86400, // 1 Day        -  3
        172800, // 2 Days      -  4    
        259200; // 3 Days      -  5

// =======*======= MONSTER SETTINGS =======*=======
// * Mob Quantity Limit depending on the map size
// - Big Maps
set .m_limit_b,100;
// - Small Maps
set .m_limit_s,30;

// * Maps List
// - Big Maps 
setarray .map_b$[0],"prontera","geffen","payon","morocc","aldebaran","alberta";
// For every map you have to add an postfix in the same order,
// which has been put in the array for the Maps
// After this, just set an array with the Mob IDs where the
// array name contains the postfix you set-up, see the examples
setarray .map_post_b$[0],"pron","gef","pay","mor","alde","alb";
// - Small Maps
setarray .map_s$[0],"izlude";
setarray .map_post_s$[0],"izl";
// ======= Monster ID's =======
// ------ Big Maps ------
// * Prontera - Mantis, Thief Bug Male, Argos, Side Winder
setarray .mob_pron[0],1139,1054,1100,1037;
// * Geffen - Poison Spore, Ghoul, Jakk, High Orc
setarray .mob_gef[0],1855,1036,1130,1213;
// * Payon - Zombie, Elder Willow, Munak, Nine Tail, Drainliar
setarray .mob_pay[0],1015,1033,1026,1180,1111;
// * Morocc - Requiem, Isis, Mummy, Minorous
setarray .mob_mor[0],1164,1029,1041,1149;
// * Aldebaran - Cramp, Penomena, Punk, Orc Archer, Bathory
setarray .mob_alde[0],1209,1029,1199,1189,1102;
// * Alberta - Pirate Skeleton, Penomena, Poison Spore, Whisper, Mimic
setarray .mob_alb[0],1071,1029,1077,1179,1191;
// ------ Small Maps ------
// * Izlude - Obeaune, Merman, Swordfish, Strouf
setarray .mob_izl[0],1044,1264,1069,1065;

// ------ Mob Amount Calculation for Big Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_b$); set .@c,.@c + 1) 
    setd(".mam_"+.map_post_b$[.@c]),( .m_limit_b/getarraysize(getd(".mob_"+.map_post_b$)) );
    
// ------ Mob Amount Calculation for Small Maps ------
for ( set .@c,0; .@c < getarraysize(.map_post_s$); set .@c,.@c + 1)
    setd(".mam_"+.map_post_s$[.@c]),( .m_limit_s/getarraysize(getd(".mob_"+.map_post_s$)) );

// ======= Final Kill Settings =======
// * Will the player who gets the final kill be rewarded?
// Only working during a Single Invasion
// - 1: Yes
// - 0: No
set .inva_final,1;

if(.inva_final == 1) {
    // * Reward Type:
    // - 1: Zeny
    // - 2: Cash Points
    // - 512+: Item ID (the Value is already the Item ID)
    set .inva_f_id,40006;
    // * Reward Amount:
    set .inva_f_am,1;
}
// =======*======= END of SETTINGS =======*=======
// Even if .delay is 0, its required to start the timer for force ending the event :I
initnpctimer;
if(.debug) {
    debugmes .n$+": .inva_delay: "+.inva_delay;
    debugmes .n$+": gettimetick(2): "+gettimetick(2);
}
if(.delay == 1 && DELAY(.delay_type,.delay_pos,1) < 1) // If the delay value is empty, set it!!
    DELAY(.delay_type,.delay_pos,2);
    
if(.debug) 
    debugmes .n$+": .inva_delay: "+.inva_delay;

if(.inva_statusinit == 1) // Starting Invasion on Server Start
    donpcevent strnpcinfo(0)+"::OnInvaInit";
// Custom Commands for GM's
bindatcmd "invastart",strnpcinfo(0)+"::OnInvaInit",1,99;
bindatcmd "invaend",strnpcinfo(0)+"::OnInvaForceEnd",1,99;
end;

function    DELAY    {
// Format: DELAY(.delay_type,.delay_pos,1/2);
// getarg(0) = Delay Type
// * 1: Random
// * 2: Fixed Delay
// * 3: Ranged Delay
// getarg(1) = Array Position if getarg(0) == 2 || 3
// getarg(2): Read/Write
// * 1: Read
// * 2: Write
if(getarg(2) == 1) 
    return (.inva_delay - gettimetick(2));
    
switch(getarg(0)) {
    case 1:    set .@new_inva,.time[rand(getarraysize(.time))]; break;
    case 2: set .@new_inva,.time[getarg(1)]; break; 
    case 3: set .@new_inva,.time[rand(getarg(1),getarraysize(.time) - 1)]; break;
}
set .inva_delay,gettimetick(2) + .@new_inva;
return .@new_inva;    
}

}
prontera,150,175,4    script    Invasion Rewarder    110,{

mes .n$;
mes "Hello, "+strcharinfo(0)+"!";
mes "So you want to be rewarded from the Mob Invasion Event, huh?";
mes "Let me take a look at your battle record.";
next;
mes .n$;
if(!InvaKill) {
    mes "It seems like you didn't participated at all or you got your reward already.";
    mes "So I can't give you any kind of reward.";
    mes "Try your best next time.";
    close;
}
mes "You haved killed "+InvaKill+" monsters, good job there.";
next;
mes .n$;
set .@rew_am,InvaKill*.rew_am;
set .@rew_bonus, ( (.rew_bonus > 0)?(InvaKill*.rew_bonus):.rew_bonus);
set .@total,.@rew_am + .@rew_bonus;

if(.rew_type == 1) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + getitemname(.rew_id)+".";
    getitem .rew_id,.@total;
} else if(.rew_type == 2) {
    mes "You have recieved "+.@total+"x "+( (.rew_bonus == 1)?"(Bonus: +"+.@rew_bonus+") ":"") + "Cash Points.";
    set #CASHPOINTS,#CASHPOINTS + (.rew_am+.rew_bonus);
}
set InvaKill,0;
close;

OnInit:
set .n$,"["+strnpcinfo(0)+"]";
// =======*======= REWARD SETTINGS =======*=======
// * Reward Type:
// - 0: None
// - 1: Item
// - 2: Cash Points
set .rew_type,1;

// * Reward Bonus
// - 0: Off
// - 1 and higher: On
// = This bonus will be given to the kill additionally.
set .rew_bonus,0;
// ----- Item -----
if(.rew_type == 1) 
    set .rew_id,7929; // Item ID    
// ----- Reward Quantity -----
set .rew_am,10; // Amount per Kill
// ----- NPC Auto Disable -----
// After how many minutes will the NPC be disabled again:
set .rew_dis,3;
disablenpc strnpcinfo(0);
end;
}

 

So looked into it a bit, and changed a few lines, first of all I wasn't replicate the "spawn monsters in batches" issue. Though gonna test more after I'm back....
So the changed version:

mob_inva.txt

I changed the way the Force End will be called and tested it with 3 minutes and worked, not sure if it worked before, but I think it didn't.
I also changed the announce way so it displays only 2 different lines, one at the usual 5 and on the last mob, otherwise it will the amount of monsters left like you requested.

Please test it yourself and gimme feedback, until then I will make some more tests regarding the spawn monsters in batches thingy.
Afterwards I will update the repo :P.

Regards,
Chris

Edited by llchrisll
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   0
  • Joined:  03/27/17
  • Last Seen:  


hi chris... You have a very interesting script, one of which is MVP Rank, I have tried this script, but can this shop point be changed according to the item I want to sell? I do not want to sell MVP Cards as in the script, if possible I want to decide for myself what I want to sell as well as the price of items that I can change.

Edited by kasim03
addition of questions
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

16 hours ago, kasim03 said:


hi chris... You have a very interesting script, one of which is MVP Rank, I have tried this script, but can this shop point be changed according to the item I want to sell? I do not want to sell MVP Cards as in the script, if possible I want to decide for myself what I want to sell as well as the price of items that I can change.

Well that script was an request based on the ideas to unlock the MvP cards that way as far as I remember. But like I stated in my topic, I'm not doing any modifications anymore only bug fixes, so sorry can't help you with that.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.01
  • Content Count:  35
  • Reputation:   1
  • Joined:  10/22/20
  • Last Seen:  

On 4/1/2021 at 5:38 PM, llchrisll said:

So looked into it a bit, and changed a few lines, first of all I wasn't replicate the "spawn monsters in batches" issue. Though gonna test more after I'm back....
So the changed version:

mob_inva.txt

I changed the way the Force End will be called and tested it with 3 minutes and worked, not sure if it worked before, but I think it didn't.
I also changed the announce way so it displays only 2 different lines, one at the usual 5 and on the last mob, otherwise it will the amount of monsters left like you requested.

Please test it yourself and gimme feedback, until then I will make some more tests regarding the spawn monsters in batches thingy.
Afterwards I will update the repo :P.

Regards,
Chris

Thank you 

so far it is working fine with the force end and the mob count

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Small info regarding some Scripts:

Dynamic Battleground Arena:
I decided to temporarly remove it from the list and GitHub repo, because when I tried to fix some errors, I crashed my map server and I don't know the reason yet why.
So I thought about rewriting most of the code, maybe I have a brain-mistake somewhere which I can't think of now or I find a better way to do stuff.
But UNTIL I have the motiviation to do that (maybe I delete it completely, who knows) I removed it.

Mob Invasion:
I wasn't able to reproduce the "mobs spawn in batches issue" no matter what I tried so I only did some adjustments and the force end fix.

Next up is the Battle Royale Script, where I screwed up the testing part for the other maps and only did it on the Alberta map and thought it should work on the others as well, which it didn't.
So that's what I'm gonna do next and then I will continue with the ROTP (RO Translation Project) again, since I took a break currently since I have to translate the Tipbox next.
I swear that's a long work..... a boring one at that ~ 5k lines :I.

Regards,
Chris aka Houndeye

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  96
  • Topics Per Day:  0.02
  • Content Count:  554
  • Reputation:   14
  • Joined:  09/24/12
  • Last Seen:  

First of all.Thx for your great script sir @llchrisll.. You are provide us a great help and customization to rathena.
 

Link to comment
Share on other sites

  • 5 months later...

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   0
  • Joined:  01/12/17
  • Last Seen:  

iam very love this script "Mystic Enchanter v1.1"

but, can you make the result of enchant/random opt is choose manually !

Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  3
  • Reputation:   0
  • Joined:  01/09/23
  • Last Seen:  

Thanks heaps chris saves me time to look for a few scripts i wanted

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.01
  • Content Count:  11
  • Reputation:   7
  • Joined:  03/20/23
  • Last Seen:  

HI,  @llchrisll about your Dungeon Quest System : I can't enter any dungeon because the npc does not let me register. He says this dungeon already reached the maximu parties it can hold. Even though I'm completely alone in my offline server. And there are some dungeons that are below my level but when I try to register it says I need to be level 90 like in Anthell and Prontera culvert. Tried to create a quest for payon dungeon but still says that it has maximu party even though I bumped up from 3 to 10.
I put the sql in the sql files of rathena and ran it into my database.

Any guiding light on how to make it work?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  625
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

On 3/26/2023 at 4:14 PM, reidouraidou said:

HI,  @llchrisll about your Dungeon Quest System : I can't enter any dungeon because the npc does not let me register. He says this dungeon already reached the maximu parties it can hold. Even though I'm completely alone in my offline server. And there are some dungeons that are below my level but when I try to register it says I need to be level 90 like in Anthell and Prontera culvert. Tried to create a quest for payon dungeon but still says that it has maximu party even though I bumped up from 3 to 10.
I put the sql in the sql files of rathena and ran it into my database.

Any guiding light on how to make it work?

Uff I would need to re-read the script as it was some time since I looked at it. But I'm too busy atm with other stuff, especially the Translation project (see Signature, in case you don't know :P).
Regards,
Chris

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...