EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Help With Random Loot Per Kill (https://www.eqemulator.org/forums/showthread.php?t=42100)

Bruser999 09-23-2018 01:22 PM

Help With Random Loot Per Kill
 
Does anyone have a custom code to help with a chance to drop completely random loot after each kill? I have seen some things where it essentially rolls a dice and if you score higher than a number, it puts a piece of gear on the corpse or summons it.

I am new to this coding on the server, so please put it in noon speak:-).

Wasn’t sure if this was done in the database tables or a .pl or .lua file.

demonstar55 09-23-2018 01:29 PM

We have global loot tables.

Bruser999 09-23-2018 02:30 PM

How do you do that? Ultimately just trying to get random loot from any mob in any way shape or form. Wanted to play 1-60 with a few friends and thought it would be fun.

superpally1 09-25-2018 09:31 PM

http://wiki.eqemulator.org/p?Diablo_...ster_Reference

And here is the example given in the wikki for using the plugin::AddLoot(amount, chance, @itemarray)

Code:

sub EVENT_SPAWN{
    plugin::AddLoot(1, 1200, 132064); # Drop 1 Minor Rainbow Crystal, 1:1200 drop
    plugin::AddLoot(1, 2750, 132065); # Drop 1 Lesser Rainbow Crystal, 1:2750 drop
    my @item_STONES = (10299, 10300, 10400, 112170);            # Light Stones
    plugin::AddLoot(8, 1, @item_STONES); # Drop 8 from list, 1/1 (100%) Chance, from Array
}


Anon.GM 09-26-2018 02:03 AM

Here is what I'm running on Anon. I know it could be tweaked better by an expert, but this works. Just change the ids to the range of items you want for the zone.

My default.pl from the zone warrens that drops crude defiant weapons and armor. Its a modified version from this link.

http://www.eqemulator.org/forums/showthread.php?t=38286

Code:


sub EVENT_SPAWN {
  $roll = int(rand(100)) + 1;
 
  $roll_chance = $roll - 70;
  $roll2_chance = $roll - 85;
  $WPlower_limit = 50500;
  $WPupper_limit = 50519;
  $ARlower_limit = 50005;
  $ARupper_limit = 50033;
       
  if($roll >= 85)
  {
      my $itemid = int(rand($WPupper_limit-$WPlower_limit)) + $WPlower_limit;
                #quest::shout("I rolled a $roll have an extra item at $roll_chance percent. Number 1 statement");
        $npc->AddItem($itemid);
                if($roll >= 75 && $mlevel >= 15)
                {
                my $itemid2 = int(rand($ARupper_limit-$ARlower_limit)) + $ARlower_limit;
                #quest::shout("I have rolled higher than 85 an extra item at $roll2_chance percent chance. Number 2 statement");
                $npc->AddItem($itemid2);
                }
        }
       
}


demonstar55 09-26-2018 12:40 PM

Quote:

Originally Posted by Bruser999 (Post 260233)
How do you do that? Ultimately just trying to get random loot from any mob in any way shape or form. Wanted to play 1-60 with a few friends and thought it would be fun.

If you're using the PEQ editor, hit the loot tab and then global loot. You can hit the plus button to set up the global loot specific stuff. Currently you can't edit the loot table here just yet, but you can go to a dummy NPC and create a loot table there and use that ID. Hopefully this will be resolved at some point :P

N0ctrnl 09-29-2018 07:05 AM

I've been using this for a few years now. Mostly to prevent the farming of greens for random drops.

Code:

sub EVENT_SPAWN {
  $roll = int(rand(1000)) + 1;

  if($roll >= 995 && $mlevel >= 46) {
    my $itemid=(132522);
    $npc->AddItem($itemid);
  }

  if($roll >= 989 && $roll <= 994 && $mlevel >= 46) {
    my $itemid=(132530);
    $npc->AddItem($itemid);
  }

  if($roll >= 910 && $roll <= 920) {
    my $itemid=(40605);
    $npc->AddItem($itemid);
  }
}

sub EVENT_HATE_LIST {
        if ($hate_state == 1 && $client && $client->GetLevel() > ($mlevel + 10) && $npc->GetEntityVariable("removed") != 1) {
                $npc->RemoveItem(132522);
                $npc->RemoveItem(40605);
                $npc->SetEntityVariable("removed", 1); #so it stops trying to remove the item when more people aggro it
        }
}


demonstar55 09-30-2018 03:58 PM

With the most recent updates to PEQ Editor you can now edit the actual loot tables from the global loot editor.

Hit the Loot tab, then click global loot, and you should be able to add or edit existing global loot entries.


This doesn't do scripted remove like n0ctrnl posted, but it does do the stuff in spawn (and more!)

Anon.GM 10-01-2018 02:33 AM

Quote:

Originally Posted by demonstar55 (Post 260276)
With the most recent updates to PEQ Editor you can now edit the actual loot tables from the global loot editor.

Hit the Loot tab, then click global loot, and you should be able to add or edit existing global loot entries.


This doesn't do scripted remove like n0ctrnl posted, but it does do the stuff in spawn (and more!)


I only use the PEQ editor in EOC and don't see this feature. I guess its coming in the near future? I have been testing the script from N0ctrnl on Anon (Solo) where I also have gobal enabled on defiant. Any other suggestions on how to add to the global loot tables without PEQ? Editing was not a problem just looking up the loot table id's but adding new items manually to the table is what I'm looking for ideas on.

keypusher 11-19-2020 09:30 PM

Is there a working version of this floating around? Links to the old wiki are dead and gitbook has a link to GeorgeS's Tools website, which is also now gone.

Xirtnil 11-21-2020 05:14 PM

This still seems to work.

Code:

sub EVENT_SPAWN {

  $roll = int(rand(100)) + 1;
 

  $roll_chance = $roll;
  $roll2_chance = $roll;
  if($roll >= 50)
  {
        my $itemid = ( int rand 95000 ) + 1001;
                quest::shout("I rolled a $roll have an extra item at $roll_chance percent. Number 1 statement");

        $npc->AddItem($itemid);
       
     
                if($roll >= 88 && $mlevel >= 51)
                {
                my $itemid2 = ( int rand 95000 ) + 1001;
                quest::shout("I have rolled higher than 85 an extra item at $roll2_chance percent chance. Number 2 statement");

                $npc->AddItem($itemid2);
               
                }
        }
       
}


deanalee 02-25-2022 11:14 AM

I know it could be tweaked better by an expert, but this works.

Just change the ids to the range of items you want for the zone.

My default.pl from the zone warrens that drops crude defiant weapons and armor.

Its a modified version from this link.

Code:

http://www.eqemulator.org/forums/showthread.php?t=38286
Code:

sub EVENT_SPAWN {
  $roll = int(rand(100)) + 1;
 
  $roll_chance = $roll - 70;
  $roll2_chance = $roll - 85;
  $WPlower_limit = 50500;
  $WPupper_limit = 50519;
  $ARlower_limit = 50005;
  $ARupper_limit = 50033;
       
  if($roll >= 85)
  {
      my $itemid = int(rand($WPupper_limit-$WPlower_limit)) + $WPlower_limit;
                #quest::shout("I rolled a $roll have an extra item at $roll_chance percent. Number 1 statement");
        $npc->AddItem($itemid);
                if($roll >= 75 && $mlevel >= 15)
                {
                my $itemid2 = int(rand($ARupper_limit-$ARlower_limit)) + $ARlower_limit;
                #quest::shout("I have rolled higher than 85 an extra item at $roll2_chance percent chance. Number 2 statement");
                $npc->AddItem($itemid2);
                }
        }
       
}


Firepaw 02-25-2022 11:30 AM

Heres a simple way of doing that where level is taken into account.

Note youll have to change some of it since its tailored to a custom server but left in comments to debug and explain what each part does :)



Code:

function event_spawn(e)
        local levelMod = math.ceil(e.self:GetLevel()/10);
        local ran = math.random(1,100);
        --e.self:Shout(tostring(levelMod)); debug
        if (ran > 90) then
                --local levelMod = math.ceil(e.self:GetLevel()/10);
                local ran2 = math.random(0,52);
                --which item in the tier drops, had 52 items in each tier

                --e.self:Shout(tostring(ran2)); debug
                if (ran < 99) then
                        levelMod = levelMod - 1;
                end
                if (levelMod > 7) then
                        levelMod = 7;
                end
                local lootdrop = levelMod * 52 + ran2 + 300000;
                -- decides what item goes on a mob. first item I wanted to drop was 300,000 ... 52 * tier

                --e.self:Shout(tostring(lootdrop)); debug
                e.self:AddItem(lootdrop, -1);
                --gives mob item

                --e.self:Shout(tostring(levelMod)); debug
        end
end


jasperarrow 03-29-2022 11:39 AM

With the most recent updates to PEQ Editor you can now edit the actual loot tables from the global loot editor.

Hit the Loot tab, then click global loot, and you should be able to add or edit existing global loot entries.


This doesn't do scripted remove like n0ctrnl posted, but it does do the stuff in spawn (and more!)


All times are GMT -4. The time now is 07:52 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.