Jump to content

Player drop difference 15 levels (type limit)(mob_drop_item.txt)


Recommended Posts

Hello community,

I like to use level_limit and type_limit because the percentage works from 1% to 100% after studying how I could check the player level and the level defined in level_limit.

In the example, the level limit is 50, so player level below (35) and 15 level above (65) can drop.

mob_drop_item.txt (example):

Group    Metin_do_Combate
{
    Level_limit    50
    Mob    8002
    Type    limit
    1    101051    1    100 -- Cofre das Habilidades
    2    101001    1    100 -- Pergaminho Esverdeado
    3    71151    5    100 -- Feitiço Verde
}

 

@src/game/item_manager.cpp

This is the hidden content, please

Thanks to @ msnas and @ Intel❤️

Edited by Papix
  • Metin2 Dev 92
  • Eyes 2
  • Good 14
  • Love 2
  • Love 15
Link to comment
Share on other sites

  • Premium

Nice job. If anybody wants the quest version of a mob_drop_item.txt that's easily customizeable:

define TYPE_LIMIT_STATIC 1
define TYPE_LIMIT_DYNAMIC 2
define TYPE_KILL 3

quest drops begin
    state start begin
        function GetDropData(vnum)
            return ({
                [8002] = {
                    ["type"] = {TYPE_LIMIT_STATIC, 50},
                    ["drops"] = {
                        {["vnum"] = 101051, ["quantity"] = 1, ["perc"] = 100},
                        {["vnum"] = 101001, ["quantity"] = 1, ["perc"] = 100},
                        {["vnum"] = 71151, ["quantity"] = 5, ["perc"] = 100},
                        -- more drops here.
                    }
                },
                -- more monsters here.
            })[vnum] or nil;
        end -- function

        when kill with not npc.is_pc() begin
            local npc_race = npc.get_race();
            local drop_data = drops.GetDropData(npc_race);
            if (drop_data == nil) then
                return;
            end -- if

            local drop_type, drop_type_arg = drop_data["type"][1], drop_data["type"][2];

            -- LIMIT_STATIC = Within 15 of a fixed level (defined in the limit's 2nd arg)
            -- LIMIT_DYNAMIC = Within 15 of target's level.
            if (drop_type == TYPE_LIMIT_STATIC or drop_type == TYPE_LIMIT_DYNAMIC) then
                local level_reference = (drop_type == TYPE_LIMIT_STATIC and drop_type_arg or npc.get_level());
                if (math.abs(pc.get_level() - level_reference) > 15) then
                    return;
                end -- if

            -- KILL = Kill a certain amount of enemies to have a chance to drop.
            elseif (drop_type == TYPE_KILL) then
                local qf_name = string.format("drop_%d_count", npc_race);
                pc.setqf(qf_name, pc.getqf(qf_name)+1);
                if (math.mod(pc.getqf(qf_name), drop_type_arg) ~= 0) then
                    return;
                end -- if
            end -- if/elseif

            for _, item_data in ipairs(drop_data["drops"]) do
                if (math.random(100) <= item_data["perc"]) then
                    game.drop_item_with_ownership(item_data["vnum"], item_data["quant"]);
                    --break; -- Uncomment if you want to limit to one drop per monster kill.
                end -- if
            end -- for
        end -- when
    end -- state
end -- quest
Spoiler

UUEcBK3.png

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • kekw 1
  • Scream 1
  • Good 3
  • Love 4

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

1 minute ago, Syreldar said:
quest drops begin
    state start begin
        function GetDropData(vnum)
            return ({
                [8002] = {
                    {["vnum"] = 101051, ["quantity"] = 1, ["perc"] = 100},
                    {["vnum"] = 101001, ["quantity"] = 1, ["perc"] = 100},
                    {["vnum"] = 71151, ["quantity"] = 5, ["perc"] = 100},
                    -- more drops here.
                },
                -- more monsters here.
            })[vnum];
        end -- function

        when kill with not npc.is_pc() and npc.get_race() == 8002 and math.abs(pc.get_level() - npc.get_level()) <= 15 begin
            local drop_data = drops.GetDropData(npc.get_race());
            for _, item_data in ipairs(drop_data) do
                if (math.random(100) <= item_data["perc"]) then
                    game.drop_item_with_ownership(item_data["vnum"], item_data["quant"]);
                    --break; -- Uncomment if you want to limit to one drop per monster kill.
                end -- if
            end -- for
        end -- when
    end -- state
end -- quest

 

UUEcBK3.png

Have a reason if the whole game is not in LUA

Edited by Metin2 Dev International
Core X - External 2 Internal
  • kekw 4
  • Lmao 1
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.