//===== Hercules Script =======================================================
//= Multiple droprate on mob elements from a set (default set: elements).
//===== By: ===================================================================
//= jaBote
//===== Current Version: ======================================================
//= 0.9.0 alpha
//===== Changelog =============================================================
//= 0.9.0 Initial version [jaBote]
//===== Description: ==========================================================
//= Implements multiple drop rates on mob sets that change each week.
//===== Warning: ==============================================================
//= -> addmonsterdrop/delmonsterdrop script commands don't work well with mobs
//= that drop the same item more than once.
//= -> Doesn't work well with @reloadscript and/or server restarts (it will
//= reassign a new set).
//===== Additional information: ===============================================
//= Configurations are located from line 22 (OnInit label).
//=============================================================================
- script element_drops -1,{
OnInit:
// Configurations START.
// Add in mob IDs on the place of the numbers
setarray .set_0[0], 1001, 1002, 1004, 1005, 1007; // Neutral
setarray .set_1[0], 1001, 1002, 1004, 1005, 1007; // Water
setarray .set_2[0], 1001, 1002, 1004, 1005, 1007; // Earth
setarray .set_3[0], 1001, 1002, 1004, 1005, 1007; // Fire
setarray .set_4[0], 1001, 1002, 1004, 1005, 1007; // Wind
setarray .set_5[0], 1001, 1002, 1004, 1005, 1007; // Poison
setarray .set_6[0], 1001, 1002, 1004, 1005, 1007; // Holy
setarray .set_7[0], 1001, 1002, 1004, 1005, 1007; // Shadow
setarray .set_8[0], 1001, 1002, 1004, 1005, 1007; // Ghost
setarray .set_9[0], 1001, 1002, 1004, 1005, 1007; // Undead
// Set to the name of the type of each set of $@set_X
// BEWARE! Number of set of this array MUST be the same than the total
// amount of sets (which is quite obvious). This is VERY IMPORTANT.
setarray .names$[0], "Neutral", "Water", "Earth", "Fire", "Wind",
"Poison", "Holy", "Shadow", "Ghost", "Undead";
// Set to the multiplication rate of drops (should be >= 1)
// Examples: 100 = x1 (useless); 200 = x2; 50 = x0.5
// Based on final drop rates after battle conf calculations.
.multiplicator = 200;
// Force change of element each week? (1 = Yes; 0 = No)
.force_change = 1;
// Text message. You can change or translate it if you want, but be careful
// not to touch the %s since you'll screw the dynamic formatting
.announce_format$ = "The element %s has been doubled for this week.";
// Atcommand name you want to use for keeping your users informed
.atcommand$ = "ddw";
// Configurations END. Don't touch unless you know what you're doing.
// Bind an atcommand
bindatcmd .atcommand$,strnpcinfo(3)+"::OnCommand";
// Get the amount of sets and use an impossible set
.amount = getarraysize(.names$);
.set = -1;
// Let it fall through the OnMon0000: label to assign first set on server
// startup (or reloadscript)
OnMon0000:
.@old_set = .set;
// Force the change of set if required
if (.force_change) {
do {
.set = rand(.amount);
} while (.set == .@old_set);
} else {
.set = rand(.amount);
}
// Restore old drops and assign new ones... if set hasn't changed
if (.@old_set != .set) {
freeloop(1); // We could be needing it
// Restoring old sets, just if there was an old set
if (.@old_set >= 0) {
.@old_set_size = getarraysize(getd( ".set_" + .@old_set));
for (.@i = 0; .@i < .@old_set_size; .@i++) {
// This is pretty ugly, but there's no other mean to do this.
.@mobid = getd( ".set_" + .@old_set + "[" + .@i + "]" );
.@drop_count = getd(".mobdrop_count_[" + .@i + "]");
for (.@j = 0; .@j <= .@drop_count; .@j++) {
// We only have to restore previously saved originals
.@drop_item = getd(".mobdrop_item_" + .@i + "[" + .@j + "]");
.@drop_rate = getd(".mobdrop_rate_" + .@i + "[" + .@j + "]");
// This updates monster drop back to original state
addmonsterdrop(.@mobid, .@drop_item, .@drop_rate);
}
}
}
// Applying multiplicator to new set
for (.@i = 0; .@i < getarraysize( getd( ".set_" + .set ) ); .@i++) {
// Get original mob drops
.@mobid = getd( ".set_" + .set + "[" + .@i + "]" );
getmobdrops(.@mobid);
setd ".mobdrop_count_[" + .@i + "]", $@MobDrop_count; // We'll need it
for (.@j = 0; .@j <= $@MobDrop_count; .@j++) {
// We only have to save originals
setd ".mobdrop_item_" + .@i + "[" + .@j + "]", $@MobDrop_item[.@i];
setd ".mobdrop_rate_" + .@i + "[" + .@j + "]", $@MobDrop_rate[.@i];
// Calculate new rate. If it gives a value out of bounds,
// addmonsterdrop will then take care of capping it inbounds
// along with a warning we can safely ignore.
.@new_rate = ($@MobDrop_rate[.@i] * .multiplicator) / 100;
// This updates monster drop item if the mob already drops it
addmonsterdrop(.@mobid, $@MobDrop_item[.@i], .@new_rate);
}
}
freeloop(0);
}
// Announce new set for everyone and finish.
.@announce_text$ = sprintf(.announce_format$, .names$[.set]);
announce .@announce_text$, bc_all|bc_blue;
end;
OnCommand:
// Announce set just for yourself and finish.
.@announce_text$ = sprintf(.announce_format$, .names$[.set]);
announce .@announce_text$, bc_self|bc_blue;
end;
}