// [jaBote] simple map or mob of the week // Thanks to Capuche for some debugging. I'm quite rusty /sob // Configs start on the OnConfig label, line 4 - script oftheweek -1,{ OnConfig: set .mapmobconfig, 2; // 0= nothing; 1 = maps; 2 = mobs; 3 = 1 + 2 = both. set .equiprobability, 1; // 0 if you want to play with relative probabilities in arrays; 1 if you want all content to be equiprobable. if (.mapmobconfig & 1) { //Leave this line alone: this is not a config but a memory optimization // Since there are more not suitable maps than suitable ones, we create a whitelist of map names, even though it's large. // Remember arrays have up to 128 positions. If you use more than 128 maps you may set a second array, and a third if you set more than 256 and so on. // You can decide not to fill up an entire array to start with another one. Use as many arrays as you want. // Fill up the arrays by yourself so you have exactly what you want setarray .maps_1$[0],"mymap1","mymap2","mymap3"; setarray .maps_2$[0],"mymap129","mymap130"; // Other settings for maps set .num_map_arrays, 2; // Set this to the number of arrays you have for maps. set .map_base_exp_multiplier, 200; // 200 means double the exp you normally would get after applying server rates; if you put 123 yould mean 1.23x. This value should be greater than 100 if you don't want weird things to happen. set .map_job_exp_multiplier, 200; // Same } if (.mapmobconfig & 2) { //Leave this line alone: this is not a config but a memory optimization // Same comment as for mobs. Fill these up with mob IDs, not mob names. Remember arrays have up to 128 positions and you may use as many as you want. setarray .mobs_1[0],1001,1002,1004,1005,1007; setarray .mobs_2[0],1584; // Other settings for maps set .num_mob_arrays, 2; // Set this to the number of arrays you have for mobs. set .mob_base_exp_multiplier, 200; // 200 means double the exp you normally would get after applying server rates; if you put 123 yould mean 1.23x. This value should be greater than 100 if you don't want weird things to happen. set .mob_job_exp_multiplier, 200; // Same } // No settings past this point set .config, 1; end; OnInit: if (gettime(4) == 0 || gettime(4) >= 5) donpcevent strnpcinfo(3)+"::OnFri0000"; // Initialise the event if it's loaded on time end; OnFri0000: // Let the bonus begin if (!.config){ donpcevent strnpcinfo(3)+"::OnConfig"; sleep 1000; // Let's give time to the OnConfig event to run } if (.mapmobconfig & 1) { // We want map of the weekend if (!.equiprobability) { // Choose a random map from a random array set .@randarray, rand(1, .num_map_arrays); set .@randpos, rand(0, getarraysize(getd(".maps_" + .@randarray + "$")) - 1); set $@specialmap$, getd(".maps_" + .@randarray + "$["+ .@randpos +"]"); // This black magic is supposed to draw a random map from the pool } else { // Equiprobability fix // We'll basically count all maps and draw a random number between 0 and number of maps. set .@totalcount, 0; for (set .@i,1; .@i <= .num_map_arrays; set .@i, .@i+1) { set .@size[.@i], getarraysize(getd(".maps_"+ .@i)); set .@totalcount, .@totalcount + .@size[.@i]; } set .@draw, rand(0, .@totalcount-1); // Now let's look for that position. for (set .@i,1; .@i <= .num_map_arrays; set .@i, .@i+1) { if (.@draw < .@size[.@i]) // We now have what we want: position in array is .@draw set $@specialmap$, getd(".maps_" + .@i + "$["+ .@draw +"]"); else set .@draw, .@draw - .@size[.@i]; // This way we approach our goal } } setmapflag $@specialmap$, mf_bexp, .map_base_exp_multiplier; setmapflag $@specialmap$, mf_jexp, .map_job_exp_multiplier; announce $@specialmap$ + " map has a x" + .map_base_exp_multiplier/100 + "." + .map_base_exp_multiplier%100+ " base exp and a x" + .map_job_exp_multiplier/100 + "." + .map_job_exp_multiplier%100 + " job exp multiplier for the weekend!",bc_all; } if (.mapmobconfig & 2) { // We want mob of the weekend if (!.equiprobability) { // Choose a random mob from a random array set .@randarray, rand(1, .num_mob_arrays); set .@randpos, rand(0, getarraysize(getd(".mobs_" + .@randarray)) - 1); set $@specialmob, getd(".mobs_" + .@randarray + "["+ .@randpos +"]"); // This black magic is supposed to draw a random mob from the pool } else { // Equiprobability fix // We'll basically count all mobs and draw a random number between 0 and number of mobs. set .@totalcount, 0; for (set .@i,1; .@i <= .num_mob_arrays; set .@i, .@i+1) { set .@size[.@i], getarraysize(getd(".mobs_"+ .@i)); set .@totalcount, .@totalcount + .@size[.@i]; } set .@draw, rand(0, .@totalcount-1); // Now let's look for that position. for (set .@i,1; .@i <= .num_mob_arrays; set .@i, .@i+1) { if (.@draw < .@size[.@i]) // We now have what we want: position in array is .@draw set $@specialmob, getd(".mobs_" + .@i + "["+ .@draw +"]"); else set .@draw, .@draw - .@size[.@i]; // This way we approach our goal } } announce getmonsterinfo($@specialmob,0) + " has a x" + .mob_base_exp_multiplier/100 + "." + .mob_base_exp_multiplier%100 + " base exp and a x" + .mob_job_exp_multiplier/100 + "." + .mob_job_exp_multiplier%100 + " job exp multiplier for the weekend!",bc_all; } donpcevent strnpcinfo(3)+"::OnDelConfig"; //This way we save memory for the week at the cost of a bit of process end; OnMon0000: // Clean up map and mob of the weekend as we won't need them anymore if ($@specialmap$ != ""){ announce "Map " + $@specialmap$ + " exp event is now ended!",bc_all; removemapflag $@specialmap$, mf_bexp; removemapflag $@specialmap$, mf_jexp; set $@specialmap$, ""; } if ($@specialmob){ announce getmonsterinfo($@specialmob,0) + " exp event is now ended!",bc_all; set $@specialmob,0; } end; OnNPCKillEvent: announce getmonsterinfo(killedrid,0),bc_self; if (.mapmobconfig & 1) { getmapxy(.@map$,.@x,.@y,0); // if (.@map$ == $@specialmap$) dispbottom "You've got more than the regular mob exp because this is the map of the weekend."; // No math necessary because of the bexp and jexp mapflags already applied to the map } if (.mapmobconfig & 2) { if (killedrid == $@specialmob){ // Now give the announce and the exp. dispbottom "You've got more than the regular mob exp because this is the mob of the weekend."; // Exp is divided by quest_exp_rate for using regular server rates. We substract 100 because the first 100% is given by the mob. // Just 1% relative error this way. set .@baseexp, getmonsterinfo($@specialmob,3)*(.mob_base_exp_multiplier - 100)/getbattleflag("quest_exp_rate"); set .@jobexp, getmonsterinfo($@specialmob,4)*(.mob_job_exp_multiplier - 100)/getbattleflag("quest_exp_rate"); getexp .@baseexp,.@jobexp; } } announce killedrid+" "+$@specialmob,bc_self; end; OnDelConfig: // Saving memory usage at the cost of a bit of process by deleting all config vars. if (.mapmobconfig & 1) { for (set .@i,1; .@i <= .num_map_arrays; set .@i, .@i+1){ deletearray getd(".maps_"+ .@i +"[0]"), getarraysize(getd(".maps_"+ .@i)); } set .num_map_arrays, 0; set .map_base_exp_multiplier, 0; set .map_job_exp_multiplier, 0; } if (.mapmobconfig & 2) { for (set .@i,1; .@i <= .num_mob_arrays; set .@i, .@i+1){ deletearray getd(".mobs_"+ .@i +"[0]"), getarraysize(getd(".mobs_"+ .@i)); } set .num_mob_arrays, 0; set .mob_base_exp_multiplier, 0; set .mob_job_exp_multiplier, 0; } set .mapmobconfig, 0; set .config, 0; end; OnPCLoginEvent: if ($@specialmap$ != "") announce $@specialmap$ + " map has a x" + .map_base_exp_multiplier/100 + "." + .map_base_exp_multiplier%100 + " base exp and a x" + .map_job_exp_multiplier/100 + "." + .map_job_exp_multiplier%100 + " job exp multiplier for the weekend!",bc_self; if ($@specialmob) announce getmonsterinfo($@specialmob,0) + " has a x" + .mob_base_exp_multiplier/100 + "." + .mob_base_exp_multiplier%100 + " base exp and a x" + .mob_job_exp_multiplier/100 + "." + .mob_job_exp_multiplier%100 + " job exp multiplier for the weekend!",bc_self; end; }