Loot based on class hate list
sub EVENT_SPAWN{
quest::setnexthpevent(50);
}
sub EVENT_HP {
my @items = (123, 456, 789); #array of items / loot tables
my @item = shuffle(@items); #Shuffle array into new array
my $loot = @item[0]; #Assign the 1st entry in new array to $loot
# Check if HP is at or below 50%
if ($hpevent == 50) {
# Get hate list of NPC
my @hate_list = $npc->GetHateList();
foreach my $ent (@hate_list) {
my $hate_entity = $ent->GetEnt();
my $hate_entity_id = $hate_entity->GetID();
my $hate_entity_class = $hate_entity->GetClass();
# Check if entity is a paladin
if ($hate_entity_class == 9) {
my $client = $entity_list->GetClientByID($hate_entity_id);
if ($client) {
# Add item 1234 to NPC1 for each Paladin on hate list
$npc->AddItem($loot, 1); # Assuming 1234 is the item ID and 1 is quantity could be swapped out for AddLootTable. item id replaced with $loot
}
}
}
}
}
This would add loot based on player classes on hatelist..3 pally's 3 items..maybe add a out of combat that would reset loot so he wouldnt end up with a ton of items.
Additionally, I would use shuffle over quest::summonitem("$items[int(rand($#items+1))]") for example
Last edited by eyenseq; 02-09-2024 at 03:26 PM..
Reason: typo
|