viewing paste rand mob spawn event v2 | Athena

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
 
 
-   script  Sample#event    -1,{
OnInit:
// mob id + amount
set .mob_id,1002;
set .mob_per_map,10;
 
// maximum how many time each day
set .times,2;
// max event hour
set .hour,2;
// map list
setarray .map$,"prontera","izlude","geffen";
 
set .map_size,getarraysize( .map$ );
set .npc_name$,strnpcinfo(0);
    
OnClock0000:
    set .@range,( 24 / .times );
    set .@start_time,gettime(3);
    for( set .@i,0; .@i < .times; set .@i,.@i + 1 ){
        set .event_time[.@i],rand( .@start_time,( .@start_time + .@range ) );
        set .@start_time,( .event_time[.@i] + .hour );
        if( .@start_time >= 24 ) break;
    }
    
OnMinute00: 
if( !.status ){
    if( gettime(3) == .event_time[0] ){
        deletearray .event_time[0],1;
        initnpctimer;
        set .status,1;
        announce "Happy Hours - "+.hour+" Hour ",bc_all;
        for( set .@i,0; .@i < .map_size; set .@i,.@i + 1 )
            monster .map$[.@i],0,0,"--ja--",.mob_id,.mob_per_map,.npc_name$+"::OnMobDied";
            
        sleep ( ( .hour * 360000 ) - ( 5 * 60000 ) );
        
        set .status,0;
        announce "Happy Hours - END",bc_all;
        for( set .@i,0; .@i < .map_size; set .@i,.@i + 1 )
            killmonster .map$[.@i],.npc_name$+"::OnMobDied";
        stopnpctimer;
    }
}
end;
 
OnTimer180000:
    if( .status ){
        for( set .@i,0; .@i < .map_size; set .@i,.@i + 1 ){
            set .@mob_count,mobcount( .map$[.@i],.npc_name$+"::OnMobDied" );
            if( .@mob_count < .mob_per_map )
                monster .map$[.@i],0,0,"--ja--",.mob_id,( .mob_per_map - .@mob_count ),.npc_name$+"::OnMobDied";
        }
        initnpctimer;
    }
    end;
 
OnWhisperGlobal:
    set .@size,getarraysize( .event_time );
    dispbottom "Upcoming Event Time : ";
    for( set .@i,0; .@i < .@size; set .@i,.@i + 1 ){
        if( .event_time[.@i] < 24 )
            dispbottom .event_time[.@i]+":00 "+(( .event_time[.@i] < 12 )?"AM":"PM" );
    }
    end;
    
OnMobDied:
    if( .status ){
        set .@rate,rand( 100 );
        // 10% get 100 apple.
        if( .@rate < 10 ){
            getitem 512,100;
        }
        // 50% get 50 apple.
        else if( .@rate < 50 ){
            getitem 512,50;
        }
        // 10% get 10 apple.
        else if( .@rate < 10 ){
            getitem 512,10;
        }
    }
    end;
}
 
 
Viewed 1374 times, submitted by Emistry.