plugin::ExtraLoot();
Just a warning up front, this is not an efficient way to do loot. This was me messing around, and trying to learn some more of perl and hashes at the time, and maybe get something partially useful out of it.
Brief Overview: This is to be used under sub EVENT_SPAWN to add loot based on the level range and category as declared in the plugin. It will choose a random category, then choose a random item in that category's level range. Every item is given equal precedence to be chosen (with the exception of armor. Armor in general is chosen as often as the other categories, but each armor type is chosen 1/4 of the time compared to the other categories. Easy fix if you like it the other way).
Currently this has defiant gear (armors, weapons, augs and offslots) and level appropriate Healing, Haste, and Buffing potions. I had debated adding in Energeiac Armor, different augs, different stat food, different potions, but I decided just to add it with just the basic defiant armors, and then add the extra stuff to my liking.
Since I use 100% custom on what I screw around on, it was easy to make a default.pl that contained plugin::ExtraLoot(); in the Spawn sub, but if you were to add this to a server with stock content, anything with its own quest would not work that way, you would have to manually edit each mob's perl. Again, this is not an efficient or even effective way to do loot. It could easily be adapted for quest rewards though.
Kudos to Tabasco for helping me get this working!
Code:
# Usage: plugin::ExtraLoot(Percent Chance, Number of Drop Chances);
# Examp: plugin::ExtraLoot(20,3); 20% chance, 3 Chances at that 20%.
# Percent Chance and Number of Drops are optional. Defaults to 10% and 2 chances. Feel free to edit if needed.
sub ExtraLoot {
my $npc = plugin::val('$npc');
my $MLevel = $npc->GetLevel();
my $PctChc = $_[0];
my $NumDrops = $_[1];
if (!defined ($PctChc)) {
$PctChc = 10;
}
if (!defined ($NumDrops)) {
$NumDrops = 2;
}
my @CategoryNames = (Armor, Augments, Weapons, Offslots, Misc);
my @ArmorTypeNames = (Plate, Chain, Leather, Cloth);
my %Categories = (
"Plate" => {
"alpha" => [50005...50011],
"beta" => [50033...50039],
"gamma" => [50061...50067],
"delta" => [50089...50095],
"epsilon" => [50117...50123],
"zeta" => [50145...50153],
"eta" => [50179...50187],
"theta" => [50213...50221],
},
"Chain" => {
"alpha" => [50012...50018],
"beta" => [50040...50046],
"gamma" => [50068...50074],
"delta" => [50096...50102],
"epsilon" => [50124...50130],
"zeta" => [50154...50161],
"eta" => [50188...50195],
"theta" => [50222...50229],
},
"Leather" => {
"alpha" => [50019...50025],
"beta" => [50047...50053],
"gamma" => [50075...50081],
"delta" => [50103...50109],
"epsilon" => [50131...50137],
"zeta" => [50162...50169],
"eta" => [50196...50203],
"theta" => [50230...50237],
},
"Cloth" => {
"alpha" => [50026...50032],
"beta" => [50054...50060],
"gamma" => [50082...50088],
"delta" => [50110...50116],
"epsilon" => [50138...50144],
"zeta" => [50170...50178],
"eta" => [50204...50212],
"theta" => [50238...50246],
},
"Augments" => {
"alpha" => [50500...50505],
"beta" => [50519...50522],
"gamma" => [50536...50537],
"delta" => [50554...50555],
"epsilon" => [50570...50571],
"zeta" => [50586...50587],
"eta" => [50602...50603],
"theta" => [50617...50618],
},
"Weapons" => {
"alpha" => [50506...50518],
"beta" => [50523...50535],
"gamma" => [50540...50553],
"delta" => [50556...50569],
"epsilon" => [50572...50585],
"zeta" => [50588...50601],
"eta" => [50604...50616],
"theta" => [50619...50631],
},
"Offslots" => {
"alpha" => [50300...50319],
"beta" => [50320...50339],
"gamma" => [50340...50359],
"delta" => [50360...50379],
"epsilon" => [50380...50399],
"zeta" => [50401...50421],
"eta" => [50422...50442],
"theta" => [50443...50463],
},
"Misc" => {
"alpha" => [77779, 77789, 77799, 77809, 77819],
"beta" => [77780, 77790, 77800, 77810, 77820],
"gamma" => [77781, 77791, 77801, 77811, 77821],
"delta" => [77782, 77792, 77802, 77812, 77822],
"epsilon" => [77783, 77793, 77803, 77813, 77823],
"zeta" => [77784, 77794, 77804, 77814, 77824],
"eta" => [77785, 77795, 77805, 77815, 77825, 77786, 77796, 77806, 77816, 77826],
"theta" => [77787, 77797, 77807, 77817, 77827, 77788, 77798, 77808, 77818, 77828],
}
);
my %LevelList = (
"70" => "theta", # Elegant Defiant
"59" => "eta", # Elaborate Defiant
"48" => "zeta", # Intricate Defiant
"37" => "epsilon", # Flawed Defiant
"26" => "delta", # Ornate Defiant
"15" => "gamma", # Rough Defiant
"05" => "beta", # Simple Defiant
"00" => "alpha", # Crude Defiant
);
foreach $key (sort keys %LevelList) {
if ($MLevel >= $key) {
$LevelCategory = $LevelList{$key};
}
}
while ($NumDrops > 0) {
my $Chance = plugin::RandomRange(1,100);
if ($PctChc >= $Chance)
{
my $DropType = $CategoryNames [rand @CategoryNames];
if ($DropType eq "Armor") {
$DropType = $ArmorTypeNames [rand @ArmorTypeNames];
}
my $ItemPool = $Categories{$DropType}{$LevelCategory};
my $Item = ${$ItemPool} [rand @{$ItemPool}];
$npc->AddItem($Item,1);
}
$NumDrops --;
}
}
return 1;
|